REGoth-project / REGoth-bs

Reimplementation of Gothic I and II using modern technologies.
https://regoth-project.github.io/REGoth-bs/index.html
MIT License
457 stars 34 forks source link

Could not load dynamic library libbsfPhysX.so #108

Open Nutomic opened 5 years ago

Nutomic commented 5 years ago

I followed the instructions here to compile Regoth on Manjaro. The compilation worked fine after installing libsquish manually. However, the binary always crashes with this error when I try to start it

$ LD_LIBRARY_PATH=../lib ./REGoth ~/gothic2/
[INFO] Booting Gothic II...
[FATAL] A fatal error occurred and the program has to terminate!
- Error: InternalErrorException
- Description: Could not load dynamic library libbsfPhysX.so.  System Error: libPhysX3_x64.so: cannot open shared object file: No such file or directory
- In function: void bs::DynLib::load()
- In file: /home/felix/workspace/regoth-bs/lib/bsf/Source/Foundation/bsfUtility/Utility/BsDynLib.cpp:40

Stack trace: 
0) ../lib/libbsf.so.1: bs::CrashHandler::getStackTrace[abi:cxx11]()+0x1f2 [0x7f1ba27ca0e2]
1) ../lib/libbsf.so.1: bs::CrashHandler::logErrorAndStackTrace(std::__cxx11::basic_string<char, std::char_traits<char>, bs::StdAlloc<char, bs::GenAlloc> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, bs::StdAlloc<char, bs::GenAlloc> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, bs::StdAlloc<char, bs::GenAlloc> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, bs::StdAlloc<char, bs::GenAlloc> > const&, unsigned int) const+0x354 [0x7f1ba27a9954]
2) ../lib/libbsf.so.1: bs::CrashHandler::reportCrash(std::__cxx11::basic_string<char, std::char_traits<char>, bs::StdAlloc<char, bs::GenAlloc> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, bs::StdAlloc<char, bs::GenAlloc> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, bs::StdAlloc<char, bs::GenAlloc> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, bs::StdAlloc<char, bs::GenAlloc> > const&, unsigned int) const+0x5f [0x7f1ba27c9aaf]
3) ../lib/libbsf.so.1: bs::DynLib::load()+0x139 [0x7f1ba2737ba9]
4) ../lib/libbsf.so.1: bs::DynLib::DynLib(std::__cxx11::basic_string<char, std::char_traits<char>, bs::StdAlloc<char, bs::GenAlloc> >)+0x52 [0x7f1ba2737d92]
5) ../lib/libbsf.so.1: bs::DynLibManager::load(std::__cxx11::basic_string<char, std::char_traits<char>, bs::StdAlloc<char, bs::GenAlloc> >)+0x289 [0x7f1ba2738939]
6) ../lib/libbsf.so.1: bs::PhysicsManager::PhysicsManager(std::__cxx11::basic_string<char, std::char_traits<char>, bs::StdAlloc<char, bs::GenAlloc> > const&, bool)+0xaf [0x7f1ba2b7db1f]
7) ../lib/libbsf.so.1: bs::CoreApplication::onStartUp()+0x4f9 [0x7f1ba2b715c9]
8) ../lib/libbsf.so.1: bs::Application::onStartUp()+0x2a [0x7f1ba2e9a1ea]
9) ./REGoth: REGoth::Engine::initializeBsf()+0xff [0x55e81b1829ef]
10) ./REGoth: REGoth::runEngine(REGoth::Engine&)+0x2b [0x55e81b18f34b]
11) ./REGoth: main+0x158 [0x55e81b1546e8]
12) /usr/lib/libc.so.6: __libc_start_main+0xf3 [0x7f1ba1bc2153]
13) ./REGoth: _start+0x2e [0x55e81b16002e]

Here is what my libs folder looks like, the file that it compains about is there.

$ ls -la ../lib/
total 688960
drwxr-xr-x 5 felix felix      4096 oct 30 20:00 ./
drwxr-xr-x 9 felix felix      4096 oct 30 21:05 ../
drwxr-xr-x 5 felix felix      4096 oct 30 00:48 bsf/
drwxr-xr-x 4 felix felix      4096 oct 30 00:48 BsZenLib/
drwxr-xr-x 5 felix felix      4096 oct 30 00:48 cxxopts/
lrwxrwxrwx 1 felix felix        22 oct 30 18:49 libbsfFBXImporter.so -> libbsfFBXImporter.so.1*
lrwxrwxrwx 1 felix felix        26 oct 30 18:49 libbsfFBXImporter.so.1 -> libbsfFBXImporter.so.1.1.0*
-rwxr-xr-x 1 felix felix  24874128 oct 30 18:49 libbsfFBXImporter.so.1.1.0*
lrwxrwxrwx 1 felix felix        23 oct 30 01:27 libbsfFontImporter.so -> libbsfFontImporter.so.1*
lrwxrwxrwx 1 felix felix        27 oct 30 01:27 libbsfFontImporter.so.1 -> libbsfFontImporter.so.1.1.0*
-rwxr-xr-x 1 felix felix   3820704 oct 30 01:27 libbsfFontImporter.so.1.1.0*
lrwxrwxrwx 1 felix felix        26 oct 30 01:27 libbsfFreeImgImporter.so -> libbsfFreeImgImporter.so.1*
lrwxrwxrwx 1 felix felix        30 oct 30 01:27 libbsfFreeImgImporter.so.1 -> libbsfFreeImgImporter.so.1.1.0*
-rwxr-xr-x 1 felix felix   5315784 oct 30 01:27 libbsfFreeImgImporter.so.1.1.0*
lrwxrwxrwx 1 felix felix        22 oct 30 18:50 libbsfGLRenderAPI.so -> libbsfGLRenderAPI.so.1*
lrwxrwxrwx 1 felix felix        26 oct 30 18:50 libbsfGLRenderAPI.so.1 -> libbsfGLRenderAPI.so.1.1.0*
-rwxr-xr-x 1 felix felix  19830600 oct 30 18:50 libbsfGLRenderAPI.so.1.1.0*
lrwxrwxrwx 1 felix felix        20 oct 30 01:26 libbsfOpenAudio.so -> libbsfOpenAudio.so.1*
lrwxrwxrwx 1 felix felix        24 oct 30 01:26 libbsfOpenAudio.so.1 -> libbsfOpenAudio.so.1.1.0*
-rwxr-xr-x 1 felix felix   6208760 oct 30 01:26 libbsfOpenAudio.so.1.1.0*
lrwxrwxrwx 1 felix felix        16 oct 30 01:27 libbsfPhysX.so -> libbsfPhysX.so.1*
lrwxrwxrwx 1 felix felix        20 oct 30 01:27 libbsfPhysX.so.1 -> libbsfPhysX.so.1.1.0*
-rwxr-xr-x 1 felix felix   8931912 oct 30 01:27 libbsfPhysX.so.1.1.0*
lrwxrwxrwx 1 felix felix        22 oct 30 19:57 libbsfRenderBeast.so -> libbsfRenderBeast.so.1*
lrwxrwxrwx 1 felix felix        26 oct 30 19:57 libbsfRenderBeast.so.1 -> libbsfRenderBeast.so.1.1.0*
-rwxr-xr-x 1 felix felix  54607696 oct 30 19:57 libbsfRenderBeast.so.1.1.0*
lrwxrwxrwx 1 felix felix        13 oct 30 01:27 libbsfSL.so -> libbsfSL.so.1*
lrwxrwxrwx 1 felix felix        17 oct 30 01:27 libbsfSL.so.1 -> libbsfSL.so.1.1.0*
-rwxr-xr-x 1 felix felix  22019840 oct 30 01:27 libbsfSL.so.1.1.0*
lrwxrwxrwx 1 felix felix        11 oct 30 01:25 libbsf.so -> libbsf.so.1*
lrwxrwxrwx 1 felix felix        15 oct 30 01:25 libbsf.so.1 -> libbsf.so.1.1.0*
-rwxr-xr-x 1 felix felix 307102056 oct 30 01:25 libbsf.so.1.1.0*
-rw-r--r-- 1 felix felix  29054604 oct 30 19:56 libBsZenLib.a
-rw-r--r-- 1 felix felix  17313480 oct 30 01:16 libdaedalus.a
-rw-r--r-- 1 felix felix 176174060 oct 30 20:00 libREGothEngine.a
-rw-r--r-- 1 felix felix   2083344 oct 30 18:49 libsamples-common.a
-rw-r--r-- 1 felix felix    826964 oct 30 00:48 libutils.a
-rw-r--r-- 1 felix felix   5047794 oct 30 00:48 libvdfs.a
-rw-r--r-- 1 felix felix  22232076 oct 30 00:49 libzenload.a

The same error happens with every single executable in the bin/ folder.

Please let me know if you need any more details.

frabert commented 5 years ago

Hi! At the bottom of the page you linked there's an info box for instructions on how to run ReGoth on Linux in case it complains about missing .so files:

If you get complains about missing .so files when you try to run an executable, try running it as LD_LIBRARY_PATH=../lib ./REGothSomething. Also, you might get an error indicating libPhysX3_x64.so not being found. You need to go into REGoth-bs/lib/bsf/Dependencies/PhysX/lib/ and copy all .so-files to the location where libbsf.so was built, usually REGoth/build/lib.

It is a kludge, but according to https://github.com/GameFoundry/bsf/issues/366 it is not fixable.

Nutomic commented 5 years ago

Maybe i should have made this more explicit. I saw that note, and I am already running with the env variable (see my first log). However, I am still getting the error.

frabert commented 5 years ago

Have you also copied the dependencies' so files to the lib directory?

Nutomic commented 5 years ago

I just tried it, but its not helping. Besides, this workaround seems to be for windows only.

frabert commented 5 years ago

Then I'm afraid we'll need to wait for someone with more experience on running REGoth on linux...

ataulien commented 5 years ago

After removing all physx .so files I had installed on my system I could reproduce this. I have yet to find a proper fix for this, but the workaround from the docs works for me.

From inside the build/bin/-directory, run the following:

# Copy the PhysX .so files if you haven't done that already
cp ../../lib/bsf/Dependencies/PhysX/lib/libPhysX3* .
# Fix the library path
export LD_LIBRARY_PATH=`pwd`/../lib:$LD_LIBRARY_PATH
# This also worked for me
LD_LIBRARY_PATH=../lib ./REGothWorldViewer -w WORLD ~/games/Gothic1
Nutomic commented 5 years ago

Thanks, that fixed the problem! So now this only needs to be added to the documentation I guess.

ataulien commented 5 years ago

It kinda is the same thing as I described in the docs, but I'll make it more obvious. We should finally figure out why the RPath is wrong on the executable and copy the .so files after building automatically...

Nutomic commented 5 years ago

Oh you're right, I only read the first half of that. Anyway, it would be clearer if the exact cp command was listed.