Cannot open shared object file: No such file or directory; Running or Debugging in Eclipse

时光毁灭记忆、已成空白 提交于 2019-11-30 12:35:12

I'm using the Kepler version of Eclipse.

  1. In Eclipse click on Run then Debug Configurations
  2. Click on the Environment Tab
  3. Click on New
  4. Add LD_LIBRARY_PATH and set its value to the directory containing the library
  5. restart Eclipse

you can use strace utility (and then grep for open and/or stat calls) to get list of .so files required to run smth, then use locate (or find among packages) to find out the actual placement of required lib

According to what @zuafi suggested , you do not have to grep for the libraries and `locate' to find them.

Instead save strace's output to a file:

strace -o my_output_file.txt /path/to/my_executable_file

then open the file, where you can see

open("/a/path/to/some/library.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)

scroll down those lines until you hit

open("/real/path/to/some/library.so", O_RDONLY|O_CLOEXEC) = 3 (any value here)

this means before finding /real/path/to/some/library.so there have been several trials to find library.so in different paths. but finally the library has been found in /real/path/to/some/.

Just copy and paste this into your Eclipse!

If you have set LD_LIBRARY_PATH and it doesn't work. Close Eclipes and run it from command terminal. I accidentally found that this could make it work. Not sure about the reason, but probably have something to do with Eclipes initialization.

This is valid with Eclipse Kepler (I have not looked into older versions). To enable the debugger to load your shared libraries, trying to set LD_LIBRARY_PATH will fail. However the CDT plugin provides a Shared Libraries list for this purpose

Run menu -> Debug Configurations ...

then in the configuration dialog

C/C++ Application -> your project -> Debugger tab -> Shared Libraries tab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!