Cannot find boost library

匿名 (未验证) 提交于 2019-12-03 08:52:47

问题:

This is a very basic question, I only post because I've spent already some time into it. This is what I've done so far:

  1. Downloaded and compiled the boost library:

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

    This way it was installed into /usr/local/lib.

  2. In my source code I've added only:

    #include <boost/asio.hpp> using boost::asio::ip::tcp
  3. I 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

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

    libboost_system.so.1.46.1 => not found

  5. But there is no error thrown, when using the -lboost_system and ls /usr/local/lib gets me among other things:

    libboost_system.so
    libboost_system.a

What am I missing?

回答1:

Did the ./bjam install tool also run the ldconfig(8) tool? ldconfig(8) needs to be run after new libraries are installed to update the caches used by ld.so(8) at program execution time.



回答2:

You should 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 makes it look for the boost library in /usr/local/lib at runtime, the -L option only makes it look in /usr/local/lib at compile time.



转载请标明出处:Cannot find boost library
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!