Author Topic: [Linux] Error while loading shared libraries  (Read 6198 times)

Offline moritz.pflanzer

  • Single posting newcomer
  • *
  • Posts: 2
[Linux] Error while loading shared libraries
« 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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: [Linux] Error while loading shared libraries
« Reply #1 on: January 01, 2011, 03:15:05 pm »
Set the LD_LIBARY_PATH appropriately or read in the linker's manual about rpath
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline moritz.pflanzer

  • Single posting newcomer
  • *
  • Posts: 2
Re: [Linux] Error while loading shared libraries
« Reply #2 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.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: [Linux] Error while loading shared libraries
« Reply #3 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.