Compiling C++ source file using Boost.Thread

后端 未结 5 863
情歌与酒
情歌与酒 2021-01-18 04:51

I am trying to learn how to use the C++ Boost.Thread library. I have installed the Boost libraries on my Ubuntu 11.10 system. I am following the book \"The Boost C++ Librar

5条回答
  •  遇见更好的自我
    2021-01-18 05:44

    That is a linking error. It means your code is correct and you include the correct headers, but the compiler doesn't link against the boost threading library. To fix this, you need to compile like this:

    g++ example61.cpp -o example61 -I /usr/local/include -lboost_thread
    

    If you've installed the Boost threading library to a non-standard path, you must also add it to the search path:

    g++ example61.cpp -o example61 -I /usr/local/include -lboost_thread -L/usr/local/lib
    

提交回复
热议问题