Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: moritz.pflanzer on December 31, 2010, 04:52:15 pm

Title: [Linux] Error while loading shared libraries
Post by: moritz.pflanzer on December 31, 2010, 04:52:15 pm
Hello,
when I try to start my console application from the terminal I get the following error:
"error while loading shared libraries: libboost_thread.so.1.45.0: cannot open shared object file: No such file or directory"
But it occurs only when I try to start the apllication from terminal. In Code::Blocks it is working properly.
I compiled the application with the following options:
- Linker settings -> Link libraries: "boost_thread"
- Search Directories -> Linker: "../boost/boost_1_45_0/stage/lib"
- The working directory is set to "."

My dir tree looks like:
./programm
./programm/boost/boost_1_45_0/stage/lib/
   -> libboost_thread.so (which is a link to libboost_thread.so.1.45.0)
   -> libboost_thread.so.1.45.0
./projectdir/
./projectdir/bin/Release

Also if I copy the two library files to the "Release" dir I'am getting the error.

I hope that's enough information otherwise please ask.
Title: Re: [Linux] Error while loading shared libraries
Post by: oBFusCATed on January 01, 2011, 03:15:05 pm
Set the LD_LIBARY_PATH appropriately or read in the linker's manual about rpath
Title: Re: [Linux] Error while loading shared libraries
Post by: moritz.pflanzer on January 03, 2011, 12:51:01 am
Thank you oBFusCATed. I'm going to use "rpath" since it seems as if many people don't recommend LD_LIBRARY_PATH.
Title: Re: [Linux] Error while loading shared libraries
Post by: Jenna on January 03, 2011, 06:53:17 am
Thank you oBFusCATed. I'm going to use "rpath" since it seems as if many people don't recommend LD_LIBRARY_PATH.
rpath means hard-coding library paths, that should not be done on linux (and on other systems), because it can break the executable , if the libraries are moved for any reasons.
If the libraries are set up correctly (should be done by the build-system or the package maintainer) it's normally not needed to do so.

THe method described here: http://wiki.codeblocks.org/index.php?title=Installing_Code::Blocks_from_source_on_Linux#Resolving_issues is preferred, if you do not want to use LD_LIBRARY_PATH.