简体   繁体   中英

C++ Executable Error: cannot open shared object file: No such file or directory

I have a project path where I have created an executable testsd :

Caspian@Caspian-VirtualBox:~/TestProject/build/linux/debug/bin/testsd

The project directory and heirarchy is as following:

/TestProject
|-build/linux/debug/bin
|-ExtLib/folder/lib(containing .a and .so files)
|-ExtLib/folder/src(containing multiple sub folders with .cpp files)
|-ExtLib/folder/include(containing multiple sub folders with .cpp files)
|-src(containing multiple sub folders with .cpp files and mainc.pp)
|-tests(containing Runtests.cpp and catch.hpp files)   

The problem is when am running this executable ( ./testsd ), I am encountering the following error:

./testsd: error while loading shared libraries: libuastackd.so: cannot open shared object file: No such file or directory

The libuastackd.so files is contained in ExtLib/folder/lib and ExtLib/folder/src/stack/lib folders. Can anyone help, how can I overcome this problem?

Thanks rG

You might set the LD_LIBRARY_PATH environment appropriately. See this . Read ld-linux.so(8) .

There is some way to set LD_LIBRARY_PATH for your entire session, eg by editing appropriately ~/.login or ~/.bashrc or ~/.bashenv or ~/.profile etc ... and this would alter the behaviour of any program you start after, including some Eclipse IDE

Read Drepper's How To Write Shared Libraries , notably for other solutions -eg appropriate -Wl,-rpath settings (which is probably what you really should use).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM