Linker error when compiling boost.asio example

穿精又带淫゛_ 提交于 2019-11-28 09:12:21

you need to link against libboost_system and apparently also against libboost_thread.

g++ -I /usr/local/boost_1_42_0 -lboost_system -lboost_thread a.cpp

in case of multi-threaded libraries:

g++ -I /usr/local/boost_1_42_0 -lboost_system-mt -lboost_thread-mt a.cpp

Have you built the boost libraries or are you trying to do this with a header-only setup? The error looks like the boost_system library is missing, which would suggest that the linker can't find the pre-built library.

You need to tell g++ where the header files are, where the libraries are and which library you are using, e.g. on my system:

g++  -I /opt/local/include -L /opt/local/lib -lboost_system-mt -lboost_thread-mt a.cpp

where -I tells g++ where the header files are and -L tells g++ where the actual libraries are and -lboost_thread-mt is the library I want to link against in the -L folder.

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