neko icon indicating copy to clipboard operation
neko copied to clipboard

[cmake] Fix libneko.so loading error when installing to `/usr/local`

Open tobil4sk opened this issue 2 years ago • 1 comments

Fixes the error: neko: error while loading shared libraries: libneko.so.2: cannot open shared object file: No such file or directory which happens when installing to /usr/local/, the default location when building from source.

tobil4sk avatar Jan 31 '23 10:01 tobil4sk

Reverted so this doesn't change the default value of RELOCATABLE, since that will have implications on nekotools boot. Also cleaned up the RPATH usage, so that during building there is no need to mess with LD_LIBRARY_PATH.

tobil4sk avatar Mar 30 '23 12:03 tobil4sk

I can't really review this, but CI is green so I'll assume that it's good!

Simn avatar May 09 '24 19:05 Simn

Do the tests still pass if RELOCATABLE is set to OFF?

andyli avatar May 09 '24 20:05 andyli

Do the tests still pass if RELOCATABLE is set to OFF?

Yes, I ran the tests locally with RELOCATABLE=OFF without issues. During testing, with RELOCATABLE=OFF the build rpath is set by default to the full build path (e.g. /.../neko/build/bin), so the executables have no issues loading the libraries from there. Then during install the rpath is updated to the install rpath (/usr/local/lib).

With RELOCATABLE=ON, CMAKE_BUILD_WITH_INSTALL_RPATH is enabled so the same rpath is used for build and install. The rpath is now $ORIGIN:/usr/local/lib for both. This means that the tests still work, since at this stage $ORIGIN is equivalent to the build directory. After install the rpath remains the same so it remains relocatable, while still being able to load from /usr/local/lib.

tobil4sk avatar May 09 '24 20:05 tobil4sk