Error while building for linux: libfmod.so.6

@dimon4deg thanks a lot!
Your solution worked exactly for me!
I had the same problem. Eventually with your solution, I ran my game on Xubuntu 16.04 using Cocos2d-x v3.16 .

Hello, i have similar error:
/cocos2d-x/TestGameDir/TestGame/bin/debug/linux/TemplateCpp: error while loading shared libraries: /cocos2d-x/TestGameDir/TestGame/cocos2d/external/linux-specific/fmod/prebuilt/64-bit/libfmod.so.6: file too short

Iā€™ve tried solution from this thread, but it didnā€™t help me at all.
By now iā€™m pissed, any help?

Tell us more. What Linux version? What Cocos2d-x version? How did you get Cocos2d-x? .zip or clone our GitHub repo?

Did you follow the instructions in our docs?

Ops, sorry about this.
My OS is Debian 9 and iā€™ve cloned Cocos2d-x from git, then followed instruction from readme.md (installed all dependancies and etc).
Iā€™ve already tried solutions: cp and add symlinks (both /usr/lib and /usr/local/lib), manually installed fmod, but it didnā€™t help me at all.
Also, i have made an issue about this on github: https://github.com/cocos2d/cocos2d-x/issues/18882.

I see. Thanks. I will have a look at the issue.

If the comments from @drelaptop donā€™t help, please tell me exactly the steps you took to install cocos2d-x and get it working. Thanks.

i have similar error.
/cocos2d-x/TestGameDir/TestGame/bin/debug/linux/TemplateCpp: error while loading shared libraries: /cocos2d-x/TestGameDir/TestGame/cocos2d/external/linux-specific/fmod/prebuilt/64-bit/libfmod.so.6: file too short

I installed Š”ocos2dx on Fedora 28, made a clone of the repository with GitHub. Did everything according to the instructions from GitHub

Did you follow our Linux install doc though?

Yes. I did everything as instructed

Off topicā€¦
Are there any plans for removing fmod?
Please check licence. I think that fmod should not be used in cocosā€¦
https://www.fmod.com/licensing

Show me all the commands you ran, please

Hello,

Iā€™ve had the same problem, with Archlinux

  • unzip the file cocos2d-x-3.17.zip in my source directories
  • creating linux-build sub-directory in ~/sources/cocos2d-x-3.17/build.
  • creating makefiles with cmake ../.. -DCMAKE_BUILD_TYPE=Release (i had built also Debug version with no changes later)
  • make -j 5

Then, when i want to launch sample (lua, C++ or Javascript), i get the same error:

 ~/sources/cocos2d-x-3.17/build/linux-build/bin/Release/cpp-tests$ ./cpp-tests                                                                                                                                     
./cpp-tests: error while loading shared libraries: /home/linox/sources/cocos2d-x-3.17/external/linux-specific/fmod/prebuilt/64-bit/libfmod.so.6: file too short

Going to the prebuilt files for fmod, i see that the versioned lib files are not symlinks as it should be, but text files containing the name of the lib.

~/sources/cocos2d-x-3.17/external/linux-specific/fmod/prebuilt/64-bit$ file *                                                                                                                                     
libfmodL.so:   ELF 64-bit LSB pie executable x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=bf0431418a9ee1ef4a3b6f5ce043aa1d998b71bb, stripped                                                                      
libfmodL.so.6: ASCII text, with no line terminators                                                                                                                                                                              
libfmod.so:    ELF 64-bit LSB pie executable x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=f50320fe8853360a3d1526fdfea8e4c63fdd15f9, stripped                                                                      
libfmod.so.6:  ASCII text, with no line terminators

~/sources/cocos2d-x-3.17/external/linux-specific/fmod/prebuilt/64-bit$ for i in *6; do echo "file \"$i\" contains: $(cat $i)"; done                                                                                
file "libfmodL.so.6" contains: libfmodL.so                                                                                                                                                                                       
file "libfmod.so.6" contains: libfmod.so

The solution is to to remove the numbered files, and to symlink them to the matching library:

 ~/sources/cocos2d-x-3.17/external/linux-specific/fmod/prebuilt/64-bit$ rm *so.6                                                                                                                                   
 ~/sources/cocos2d-x-3.17/external/linux-specific/fmod/prebuilt/64-bit$ ln -s libfmodL.so libfmodL.so.6                                                                                                            
 ~/sources/cocos2d-x-3.17/external/linux-specific/fmod/prebuilt/64-bit$ ln -s libfmod.so libfmod.so.6

And it works, as you can see, the rpath linking is working:

~/sources/cocos2d-x-3.17/build/linux-build/bin/Release/cpp-tests$ ldd cpp-tests | grep -i fmod                                                                                                                    
        libfmod.so.6 => /home/linox/sources/cocos2d-x-3.17/external/linux-specific/fmod/prebuilt/64-bit/libfmod.so.6 (0x00007ff8b793c000)

I believe that linux users without problems on this one are those with fmod libs already installed. As they are found in the LD path (usually /usr/lib), rpath hardcoded lib is not used. Well, i think :slight_smile:

Thank you for reading :slight_smile:

4 Likes