Undefined reference to boost::system::generic_category despite linking with boost_system [duplicate]

元气小坏坏 提交于 2019-12-24 02:30:33

问题


My compilation command is:

g++ -I/home/foo/boost_1_56_0 -L/home/foo/boost_1_56_0/stage/lib -lboost_system -lboost_filesystem -lpthread -lboost_thread -lboost_system -lboost_filesystem -lpthread -lboost_thread main.cpp foo.cpp

I get an undefined reference to boost::system::generic_category error despite the fact that I link it with -lboost_thread.

I also get undefined references to:

boost::system::generic_category and pthread_detach.


回答1:


You should specify the libraries after the source file(s).

Also, prefer -pthread over manually linking libpthread.so

g++ -I/home/foo/boost_1_56_0 -L/home/foo/boost_1_56_0/stage/lib -pthread main.cpp foo.cpp -lboost_system -lboost_filesystem -lboost_thread



来源:https://stackoverflow.com/questions/26317955/undefined-reference-to-boostsystemgeneric-category-despite-linking-with-boos

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