Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
May 9, 2024

Conversation

tobil4sk
Copy link
Member

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 tobil4sk force-pushed the usr-local-install branch from 868056f to fdbd096 Compare March 30, 2023 12:05
@tobil4sk
Copy link
Member Author

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 added 3 commits May 9, 2024 12:38
This way rpath is correctly set by default, avoiding errors like:
`libneko.so.2: cannot open shared object file` when installing to
/usr/local/
If rpath is set correctly then this is not necessary
Only build with install path if RELOCATABLE is on, otherwise we can stick to
the default build rpath.

We were setting these options to their default values:
CMAKE_MACOS_RPATH, CMAKE_SKIP_BUILD_RPATH, CMAKE_SKIP_INSTALL_RPATH
@Simn
Copy link
Member

Simn commented May 9, 2024

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

@Simn Simn merged commit 7fbf5d6 into HaxeFoundation:master May 9, 2024
12 checks passed
@tobil4sk tobil4sk deleted the usr-local-install branch May 9, 2024 19:33
@andyli
Copy link
Member

andyli commented May 9, 2024

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

@tobil4sk
Copy link
Member Author

tobil4sk commented May 9, 2024

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.

CMakeLists.txt Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants