How to link boost libraries properly in Linux

前端 未结 2 1694
死守一世寂寞
死守一世寂寞 2021-02-08 20:37

I\'ve been trying to go through Boost tutorials but I got stuck at linking the filesystem library.

I have Ubuntu 12.10. Installation wasn\'t that hard

su         


        
相关标签:
2条回答
  • 2021-02-08 21:25

    The -L command should be the base path where the libraries are contained, not the path to a specific library. Try with -L /usr/lib/ instead.

    0 讨论(0)
  • 2021-02-08 21:30

    I found the answer myself here:
    http://www.richelbilderbeek.nl/CppLinkErrorUndefinedReferenceToBoostFilesystemDetailGet_current_path_api.htm
    Looks like binaries weren't in /usr/lib but in /usr/local/lib.
    So the correct command for compilation would be:

    g++ -g tut1.cpp -o tut1 -L/usr/local/lib/ -lboost_filesystem
    

    @Yuushi, that was 1 problem.

    0 讨论(0)
提交回复
热议问题