Yet another c++ error that isn’t immediate to recover: I wanted to compile and run a program that uses the awesome Boost libraries, but after successfully compiling the program against the libraries I managed to download and install I got the error in the title.
After some googling, I found that you have to add the path to the boost libraries to the environment variable LD_LIBRARY_PATH
. You can check whether that’s the problem you have by running your program in a shell like this:
export LD_LIBRARY_PATH=/usr/local/lib/:$LD_LIBRARY_PATH ./my_program
Replace /usr/local/lib/
with the path you chose to install boost libraries to (that’s the default path if you installed them as root).
If your program runs fine, there’s your problem!
To make changes permanent in Ubuntu you have to add a new configuration file for ldconfig:
sudo vim /etc/ld.so.conf.d/libboost.conf
(my editor of choice is VIM, and the name of the file itself doesn’t matter)
Add the library path to that file, i.e. /usr/local/lib/
.
Save the file, quit and reload your configuration by calling
sudo ldconfig
Note that your LD_LIBRARY_PATH
won’t change, but your program will now run!