0

Since I don't have root permission to install Boost C++ library, I installed it under my home local. When compiling, I used: g++ -I/home/name/local/boost_1_47_0 -L/home/name/local/boost_1_47_0/stage/lib foo.cc -o foo -lboost_program_options

but at runtime, it goes: error while loading shared libraries: libboost_program_options.so.1.47.0: cannot open shared object file: No such file or directory

and ldd gives: libboost_program_options.so.1.47.0 => not found

I also tried to specify the absolute path of the library, but it doesn't work either: g++ /home/name/local/boost_1_47_0/stage/lib/libboost_program_options.so.1.47.0 -I/home/name/local/boost_1_47_0 -L/home/name/local/boost_1_47_0/stage/lib foo.cc -o foo

MSalters
  • 173,980
  • 10
  • 155
  • 350
JDai
  • 13
  • 2
  • 6

2 Answers2

4

Try using the LD_LIBRARY_PATH environment variable to instruct the run-time linker where to find the library:

export LD_LIBRARY_PATH=/home/name/local/boost_1_47_0/stage/lib

Then rerun your application.

Kyle Lutz
  • 7,966
  • 2
  • 20
  • 23
  • It's worth noting that this isn't a good long term solution to the problem. Eventually you'll either want to require that boost_program_options find its way into the system library search path sans LD_LIBRARY_PATH, or use a runpath with a local shared library. See http://blogs.oracle.com/rie/date/20040710 – tyree731 Sep 22 '11 at 14:07
  • If you cannot install to the system places I would use static libraries for the release so LD_LIBRARY_PATH is not required – mmmmmm Sep 25 '11 at 10:23
0

I'm a newbie, so don't take my words too seriously. Furthermore, this question is several months old and I guess solved long ago. Nevertheless, here's what I think.

You specify the library path to the linker, so the program compiles and links fine. However, when you try to execute the binary, it looks for the libs in the environment defined path.

I guess this can be fixed by typing into bash

export PATH=$PATH:path_to_your_library_folder

Best Regards Miroslav

Vorac
  • 8,726
  • 11
  • 58
  • 101