Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiled C++ program raises "cannot open shared object file" on another system though the file is present

I wrote a tiny program that requires some libraries including libboost_filesystem, libboost_program_options and libcurl.

I compiled it on my home machine and took the binary to my computer at work to test it there. But there it gives the following error message when I try to start the program:

error while loading shared libraries:
libboost_filesystem.so.1.42.0: cannot
open shared object file

But when I search for this file I see that it exists in: /usr/lib/libboost_filesystem.so.1.42.0

Did I something wrong during the compilation / linking of my program? If yes what do I have to do to make it work on other machines?

like image 866
tyrondis Avatar asked Nov 02 '10 13:11

tyrondis


2 Answers

First, try to issue ldconfig -p | grep libboost_filesystem.so in a console to make sure the library is in your ld cache.

If it is not, you may need to add a file with a name like boost.conf to your /etc/ld.so.conf.d directory. This file should contain a path to your boost libraries. Then run sudo ldconfig to update your system's ld cache.

Hope this will help...

like image 115
ezpresso Avatar answered Sep 28 '22 02:09

ezpresso


Looks like you need to statically link the library. Here's a good explanation. Boost static linking

like image 40
prasanna Avatar answered Sep 28 '22 02:09

prasanna