-
Notifications
You must be signed in to change notification settings - Fork 3.4k
CMake shared libraries error: shared library dependency not found in library path
#24195
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
Comments
Normally when libB.so depends on libA.so its is passed on the command line either as Also, in this case you might as well just use |
Thank you for your help! I created a minimal reproducer: https://github.com/donalffons/emscripten-cmake-dynamic-libraries This builds and runs fine with a native build using gcc on linux. It has the following structure: graph LR
Main --> B
B --> A
When I try to build this with Emscripten, I get this error:
Interestingly, the same error appears when I link A into B using an absolute path: target_link_libraries(B PRIVATE "/home/user/emscripten-cmake-dynamic-libraries/build/A/libA.so") |
Thanks for the simple repro @donalffons. (BTW, can I recommend that you switch to |
CC @hoodmane who is probably the biggest users of emscripten shared libraries. |
cc @ryanking13 who usually fixes the cmake problems in Pyodide. |
Thank you both! Here is the output of
...apparently, it's just adding
But it doesn't contain the path to that library (even when I'm using absolute paths in Also, when I'm running a native build, this
|
If Can you share the link command for |
Here is the verbose output of
EDIT: And here it is for a native build:
|
...just realized that |
...but, the |
What does |
|
So the RUNPATH here is key. When you link |
When building with Emscripten, the string
I'm currently on Emscripten v4.0.4. Are you suggesting that this might have already been resolved on the current main branch? I just tried using |
We need to figure out why cmake is not inserting the |
Is it actually related to RPATH? It looks like the problem is happening in the linking stage not in runtime. |
FWIW, what Pyodide does to tackle with shared libraries + CMake is to write a separate Cmake toolchain file which enables shared modules and adds side module flags, and passing it when calling emcmake (1, 2) (using |
I yes, it looks like its actually simply the link time path It looks like the part that should be enough to make it work here is |
Here is the relevant section of the
and here when using
I tried manually editing the
( EDIT: And there is no mention of a string like |
If you want |
After the modifications to the
...strangely,
Thank you all for your help until here - this is much appreciated. This thread gave me a lot of new clues that I'll look into, next week. In case you have other ideas, please let me know 🙂. |
Uh oh!
There was an error while loading. Please reload this page.
I am compiling a large CMake code base to Emscripten, where certain libraries must be compiled into dynamically linked libraries. Since Emscripten doesn't support
add_library(... SHARED ...)
by default, I am trying to use this workaround (another approach would be to useadd_executable(...)
with-sSIDE_MDOULE=1
- but that would require refactoring of a very large number of CMake files, which I want to avoid).That approach almost works, except for this: I am building two shared libraries,
A
andB
.A
defines thatB
should be added as a linked library:With that, the build fails with this error:
Is there a way to modify this library path, mentioned in the error message? Has anyone managed to get this to work? Any help would be much appreciated!
The text was updated successfully, but these errors were encountered: