Unable to find forced library

This is a very simple question, I only post, because I spent some time on it. This is what I have done so far:

  • The boost library is loaded and compiled:

    sudo ./bootstrap.sh and sudo ./bjam install

    Thus, it was installed in /usr/local/lib .

  • In my source code, I added only:

     #include <boost/asio.hpp> using boost::asio::ip::tcp 
  • I will compile it with

    g++ -I/usr/lib/jvm/java-6-openjdk/include -L/usr/local/lib -fPIC -lboost_system -shared -o libagent.so agent.cpp

  • However, ldd -d ./libagent.so gives me:

    libboost_system.so.1.46.1 => not found

  • But the error does not occur when -lboost_system and ls /usr/local/lib , I am among other things:

    libboost_system.so
    libboost_system.a

What am I missing?

+4
source share
2 answers

./bjam install tool also run the ldconfig(8) tool? ldconfig(8) must be started after installing new libraries to update the caches used by ld.so(8) at run time.

+3
source

You must compile it with:

 g++ -I/usr/lib/jvm/java-6-openjdk/include -L/usr/local/lib -Wl,-rpath,/usr/local/lib -fPIC -lboost_system -shared -o libagent.so agent.cpp 

This forces you to search for the boost library in / usr / local / lib at run time, the -L option only causes it to search in / usr / local / lib at compile time.

+2
source

Source: https://habr.com/ru/post/1345054/


All Articles