当前文章: 首页 >> 编程开发 >> Qt >> /usr/include/boost/system/error_code.hpp:214: undefined reference to `boost::system::generic_categor
«   2019年10月   »
123456
78910111213
14151617181920
21222324252627
28293031
网站分类
控制面板
您好,欢迎到访网站!
  查看权限
标签列表
最近发表

/usr/include/boost/system/error_code.hpp:214: undefined reference to `boost::system::generic_categor

使用QT做boost开发时,一编译出错了,由于我已经安装了boost,想必也是库的问题。

代码:

#include <boost/thread.hpp>

void run()
{

}

int main(int argc, char *argv[])
{
    boost::thread_group ths;
    //
    ths.create_thread(run);

    ths.join_all();
}


错误:

12:26:07: 为项目demo001执行步骤 ...
12:26:07: 正在启动 "/bin/qmake-qt5" /home/jues/workspce/QT/demo001/demo001.pro -spec linux-g++ CONFIG+=debug CONFIG+=qml_debug

12:26:07: 进程"/bin/qmake-qt5"正常退出。
12:26:07: 正在启动 "/bin/make" qmake_all

make: 对“qmake_all”无需做任何事。
12:26:07: 进程"/bin/make"正常退出。
12:26:07: 正在启动 "/bin/make" 

g++ -c -pipe -g -std=gnu++11 -Wall -W -D_REENTRANT -fPIC -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../demo001 -I. -isystem /usr/include/qt5 -isystem /usr/include/qt5/QtWidgets -isystem /usr/include/qt5/QtGui -isystem /usr/include/qt5/QtCore -I. -isystem /usr/include/libdrm -I. -I/usr/lib64/qt5/mkspecs/linux-g++ -o main.o ../demo001/main.cpp
g++ -c -pipe -g -std=gnu++11 -Wall -W -D_REENTRANT -fPIC -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../demo001 -I. -isystem /usr/include/qt5 -isystem /usr/include/qt5/QtWidgets -isystem /usr/include/qt5/QtGui -isystem /usr/include/qt5/QtCore -I. -isystem /usr/include/libdrm -I. -I/usr/lib64/qt5/mkspecs/linux-g++ -o mainwindow.o ../demo001/mainwindow.cpp
/usr/lib64/qt5/bin/moc -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB --include ./moc_predefs.h -I/usr/lib64/qt5/mkspecs/linux-g++ -I/home/jues/workspce/QT/demo001 -I/usr/include/qt5 -I/usr/include/qt5/QtWidgets -I/usr/include/qt5/QtGui -I/usr/include/qt5/QtCore -I. -I/usr/include/c++/4.8.5 -I/usr/include/c++/4.8.5/x86_64-redhat-linux -I/usr/include/c++/4.8.5/backward -I/usr/lib/gcc/x86_64-redhat-linux/4.8.5/include -I/usr/local/include -I/usr/include ../demo001/mainwindow.h -o moc_mainwindow.cpp
g++ -c -pipe -g -std=gnu++11 -Wall -W -D_REENTRANT -fPIC -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../demo001 -I. -isystem /usr/include/qt5 -isystem /usr/include/qt5/QtWidgets -isystem /usr/include/qt5/QtGui -isystem /usr/include/qt5/QtCore -I. -isystem /usr/include/libdrm -I. -I/usr/lib64/qt5/mkspecs/linux-g++ -o moc_mainwindow.o moc_mainwindow.cpp
g++  -o demo001 main.o mainwindow.o moc_mainwindow.o   -lQt5Widgets -lQt5Gui -lQt5Core -lGL -lpthread 
main.o: In function `__static_initialization_and_destruction_0(int, int)':
/usr/include/boost/system/error_code.hpp:214: undefined reference to `boost::system::generic_category()'
/usr/include/boost/system/error_code.hpp:215: undefined reference to `boost::system::generic_category()'
/usr/include/boost/system/error_code.hpp:216: undefined reference to `boost::system::system_category()'
main.o: In function `boost::thread_exception::thread_exception(int, char const*)':
/usr/include/boost/thread/exceptions.hpp:51: undefined reference to `boost::system::system_category()'
main.o: In function `boost::condition_error::condition_error(int, char const*)':
/usr/include/boost/thread/exceptions.hpp:84: undefined reference to `boost::system::system_category()'
main.o: In function `boost::detail::thread_data_base::thread_data_base()':
/usr/include/boost/thread/pthread/thread_data.hpp:142: undefined reference to `vtable for boost::detail::thread_data_base'
main.o: In function `boost::detail::interruption_checker::interruption_checker(pthread_mutex_t*, pthread_cond_t*)':
/usr/include/boost/thread/pthread/thread_data.hpp:185: undefined reference to `boost::detail::get_current_thread_data()'
main.o: In function `boost::thread::start_thread()':
/usr/include/boost/thread/detail/thread.hpp:180: undefined reference to `boost::thread::start_thread_noexcept()'
main.o: In function `boost::thread::~thread()':
/usr/include/boost/thread/detail/thread.hpp:255: undefined reference to `boost::thread::detach()'
main.o: In function `boost::condition_variable::wait(boost::unique_lock<boost::mutex>&)':
/usr/include/boost/thread/pthread/condition_variable.hpp:84: undefined reference to `boost::this_thread::interruption_point()'
main.o: In function `boost::shared_mutex::lock()':
/usr/include/boost/thread/pthread/shared_mutex.hpp:169: undefined reference to `boost::this_thread::disable_interruption::disable_interruption()'
/usr/include/boost/thread/pthread/shared_mutex.hpp:178: undefined reference to `boost::this_thread::disable_interruption::~disable_interruption()'
/usr/include/boost/thread/pthread/shared_mutex.hpp:178: undefined reference to `boost::this_thread::disable_interruption::~disable_interruption()'
main.o: In function `boost::detail::thread_data<void (*)()>::~thread_data()':
/usr/include/boost/thread/detail/thread.hpp:91: undefined reference to `boost::detail::thread_data_base::~thread_data_base()'
main.o:(.data.rel.ro._ZTIN5boost6detail11thread_dataIPFvvEEE[_ZTIN5boost6detail11thread_dataIPFvvEEE]+0x10): undefined reference to `typeinfo for boost::detail::thread_data_base'
collect2: error: ld returned 1 exit status
make: *** [demo001] Error 1
12:26:22: 进程"/bin/make"退出,退出代码 2 。
Error while building/deploying project demo001 (kit: 桌面)
When executing step "Make"
12:26:22: Elapsed time: 00:16.


解决:

在工程pro文件中添加以下内容

# boost
LIBS += -lboost_system -lboost_thread


声明:本站原创文章,转载、复制、使用等请注明出处。
标题/usr/include/boost/system/error_code.hpp:214: undefined reference to `boost::system::generic_categor
作者jues
地址: http://blog.jues.org.cn/post/usrincludeboostsystemerrorcode.hpp214-undefined-reference-to-boostsystemgenericcategor.html

发表评论:

Powered By Z-BlogPHP 1.5.2 Zero Powered By Z-BlogPHP © 2018 jues博客 Copyright Your WebSite.Some Rights Reserved.联系站长 Themes by jues