最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c++ - binld cannot find *.so library needed by another library - Stack Overflow

programmeradmin1浏览0评论

I am trying to use Ninja to generate an AARCH64 application in my x86_64 Linux machine. The cmake compile + generation proceeds fine. This seems to be a cross-compilation issue.

But when I run ninja install it throws this error:

[98/1000] Linking CXX executable
/aarch64-linux-gnu/bin/ld: warning: myLibrary.so.39, needed by /home/project/astrosky/lib/astrosky.so, not found (try using -rpath or -rpath-link)

myLibrary.so.39 has a symbolic link to myLibrary.so.39.3. Both libraries exist in the same directory + the symbolic link is not broken. The architecture of these *.so files are AARCH64.

Things I've done.

  1. Verified that both libraries exist and are where I expect them to be: /home/project/deps/
  2. Specify to use the ldconfig for AARHC64.
  3. Created my own /etc/ld.so.conf.d/aarch-linux-gnu.conf file so it points to the directory that has the *.so files. I deleted the ld cache & re-generated the cache for ldconfig.
  4. Double-check that ldconfig -p sees myLibrary.so.39 and is symlink'd to myLibrary.so.39.3. It also sees all the other libraries in /home/project/deps/.
  5. Set env var: LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/project/deps

Resources I've looked at but did not fix the issue:

  • /usr/bin/ld cannot find shared library
  • /usr/bin/ld cannot find library
  • /usr/bin/ld cannot find library

I am trying to use Ninja to generate an AARCH64 application in my x86_64 Linux machine. The cmake compile + generation proceeds fine. This seems to be a cross-compilation issue.

But when I run ninja install it throws this error:

[98/1000] Linking CXX executable
/aarch64-linux-gnu/bin/ld: warning: myLibrary.so.39, needed by /home/project/astrosky/lib/astrosky.so, not found (try using -rpath or -rpath-link)

myLibrary.so.39 has a symbolic link to myLibrary.so.39.3. Both libraries exist in the same directory + the symbolic link is not broken. The architecture of these *.so files are AARCH64.

Things I've done.

  1. Verified that both libraries exist and are where I expect them to be: /home/project/deps/
  2. Specify to use the ldconfig for AARHC64.
  3. Created my own /etc/ld.so.conf.d/aarch-linux-gnu.conf file so it points to the directory that has the *.so files. I deleted the ld cache & re-generated the cache for ldconfig.
  4. Double-check that ldconfig -p sees myLibrary.so.39 and is symlink'd to myLibrary.so.39.3. It also sees all the other libraries in /home/project/deps/.
  5. Set env var: LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/project/deps

Resources I've looked at but did not fix the issue:

  • /usr/bin/ld cannot find shared library
  • /usr/bin/ld cannot find library
  • /usr/bin/ld cannot find library
Share Improve this question edited Mar 14 at 22:33 Ulrich Eckhardt 17.5k5 gold badges31 silver badges60 bronze badges asked Mar 14 at 19:11 JamieJamie 1,1992 gold badges15 silver badges33 bronze badges 1
  • Edit your question with the full link command that's failing. – Stephen Newell Commented Mar 14 at 19:25
Add a comment  | 

1 Answer 1

Reset to default 0

2 things

passing search paths to ld

afaict, it is not the runtime linker (which is configured with LD_LIBRARY_PATH resp /etc/ld.so.conf.d/*.conf, but your link editor (aka ld)

You can tell your link editor where to look for dynamic libraries by using the -L flag (aka -L/path/to/mlib -lmyLibrary

library names

telling the link editor to link a library with the -l flag, will really (only) make it search for libraries that are prefixed with lib. that is -lmyLibrary will require a file libmyLibrary.so to exist in the search paths.

if you library lacks the lib prefix (e.g. myLibrary.so, as you indicated in your Q), I think you need to pass the full path to the linker (e.g. /path/to/myLibrary.so, without any -L or -l flags)

发布评论

评论列表(0)

  1. 暂无评论