epolloneshot_test.cpp:(.text+0x582): undefined reference to `pthread_create‘

博客提及编译指令需在尾部添加,但未给出更多详细信息。

编译指令需要在尾部加上-lpthread,如下:

g++ -o epolloneshot_test epolloneshot_test.cpp -lpthread
/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: /opt/rh/devtoolset-9/root/usr/lib/gcc/x86_64-redhat-linux/9/libstdc++_nonshared.a(thread48.o): in function `std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)())': (.text._ZNSt6thread15_M_start_threadESt10unique_ptrINS_6_StateESt14default_deleteIS1_EEPFvvE+0x11): undefined reference to `pthread_create' /opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: /opt/rh/devtoolset-9/root/usr/lib/gcc/x86_64-redhat-linux/9/libstdc++_nonshared.a(thread48.o): in function `std::thread::_M_start_thread(std::shared_ptr<std::thread::_Impl_base>, void (*)())': (.text._ZNSt6thread15_M_start_threadESt10shared_ptrINS_10_Impl_baseEEPFvvE+0x60): undefined reference to `pthread_create' /opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: test.o: in function `std::thread::thread<ThreadPool::ThreadPool(int)::{lambda()#1}, , void>(ThreadPool::ThreadPool(int)::{lambda()#1}&&)': test.cpp:(.text._ZNSt6threadC2IZN10ThreadPoolC4EiEUlvE_JEvEEOT_DpOT0_[_ZNSt6threadC5IZN10ThreadPoolC4EiEUlvE_JEvEEOT_DpOT0_]+0x21): undefined reference to `pthread_create' /opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: log.o: in function `std::thread::thread<void (&)(), , void>(void (&)())': log.cpp:(.text._ZNSt6threadC2IRFvvEJEvEEOT_DpOT0_[_ZNSt6threadC5IRFvvEJEvEEOT_DpOT0_]+0x21): undefined reference to `pthread_create' /opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: sqlconnpool.o: in function `SqlConnPool::GetConn()': sqlconnpool.cpp:(.text+0x13d): undefined reference to `sem_wait' /opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: sqlconnpool.o: in function `SqlConnPool::FreeConn(MYSQL*)': sqlconnpool.cpp:(.text+0x207): undefined reference to `sem_post' /opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: sqlconnpool.o: in function `SqlConnPool::Init(char const*, int, char const*, char const*, char const*, int)': sqlconnpool.cpp:(.text+0x2e7): undefined reference to `mysql_init' /opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: sqlconnpool.cpp:(.text+0x3a5): undefined reference to `mysql_real_connect' /opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: sqlconnpool.cpp:(.text+0x45d): undefined reference to `sem_init' /opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: sqlconnpool.o: in function `SqlConnPool::ClosePool()': sqlconnpool.cpp:(.text+0x4ce): undefined reference to `mysql_close' /opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: sqlconnpool.cpp:(.text+0x4d5): undefined reference to `mysql_server_end' collect2: error: ld returned 1 exit status make: *** [test1] 错误 1,逐条分析错误
07-25
[main] 正在生成文件夹: /home/aiec/Templates/test/build all [build] 正在启动生成 [proc] 正在执行命令: /usr/bin/cmake --build /home/aiec/Templates/test/build --config Debug --target all -j 8 -- [build] Consolidate compiler generated dependencies of target CrossCompileProject [build] [ 50%] Linking CXX executable bin/CrossCompileProject [build] /usr/bin/ld: /usr/lib/aarch64-linux-gnu/libopencv_videoio.a(cap_gstreamer.cpp.o): in function `cv::GStreamerCapture::retrieveFrame(int, cv::_OutputArray const&)': [build] (.text._ZN2cv16GStreamerCapture13retrieveFrameEiRKNS_12_OutputArrayE+0x2b4): undefined reference to `gst_video_info_from_caps' [build] /usr/bin/ld: /usr/lib/aarch64-linux-gnu/libopencv_videoio.a(cap_gstreamer.cpp.o): in function `cv::handleMessage(_GstElement*)': [build] (.text._ZN2cvL13handleMessageEP11_GstElement+0xdc): undefined reference to `gst_is_missing_plugin_message' [build] /usr/bin/ld: /usr/lib/aarch64-linux-gnu/libopencv_videoio.a(cap_gstreamer.cpp.o): in function `cv::CvVideoWriter_GStreamer::open(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, double, cv::Size_<int> const&, cv::VideoWriterParameters const&)': [build] (.text._ZN2cv23CvVideoWriter_GStreamer4openERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEidRKNS_5Size_IiEERKNS_21VideoWriterParametersE+0x16b4): undefined reference to `gst_riff_create_video_caps' [build] /usr/bin/ld: (.text._ZN2cv23CvVideoWriter_GStreamer4openERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEidRKNS_5Size_IiEERKNS_21VideoWriterParametersE+0x1724): undefined reference to `gst_encoding_container_profile_new' [build] /usr/bin/ld: (.text._ZN2cv23CvVideoWriter_GStreamer4openERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEidRKNS_5Size_IiEERKNS_21VideoWriterParametersE+0x1744): undefined reference to `gst_encoding_video_profile_new' [build] /usr/bin/ld: (.text._ZN2cv23CvVideoWriter_GStreamer4openERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEidRKNS_5Size_IiEERKNS_21VideoWriterParametersE+0x1764): undefined reference to `gst_encoding_container_profile_add_profile' [build] /usr/bin/ld: /usr/lib/aarch64-linux-gnu/libopencv_videoio.a(cap_v4l.cpp.o): in function `cv::CvCaptureCAM_V4L::convertToRgb(cv::Buffer const&)': [build] (.text._ZN2cv16CvCaptureCAM_V4L12convertToRgbERKNS_6BufferE+0x610): undefined reference to `cv::imdecode(cv::_InputArray const&, int, cv::Mat*)' [build] /usr/bin/ld: /usr/lib/aarch64-linux-gnu/libopencv_videoio.a(cap_images.cpp.o): in function `cv::CvCapture_Images::grabFrame()': [build] (.text._ZN2cv16CvCapture_Images9grabFrameEv+0x60): undefined reference to `cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)' [build] /usr/bin/ld: /usr/lib/aarch64-linux-gnu/libopencv_videoio.a(cap_images.cpp.o): in function `cv::CvVideoWriter_Images::open(char const*)': [build] (.text._ZN2cv20CvVideoWriter_Images4openEPKc+0x134): undefined reference to `cv::haveImageWriter(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' [build] /usr/bin/ld: /usr/lib/aarch64-linux-gnu/libopencv_videoio.a(cap_images.cpp.o): in function `cv::CvCapture_Images::open(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)': [build] (.text._ZN2cv16CvCapture_Images4openERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x1b4): undefined reference to `cv::haveImageReader(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' [build] /usr/bin/ld: /usr/lib/aarch64-linux-gnu/libopencv_videoio.a(cap_images.cpp.o): in function `cv::CvVideoWriter_Images::writeFrame(_IplImage const*)': [build] (.text._ZN2cv20CvVideoWriter_Images10writeFrameEPK9_IplImage+0x100): undefined reference to `cv::imwrite(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&, std::vector<int, std::allocator<int> > const&)' [build] /usr/bin/ld: /usr/lib/aarch64-linux-gnu/libopencv_videoio.a(cap_mjpeg_decoder.cpp.o): in function `cv::MotionJpegCapture::retrieveFrame(int, cv::_OutputArray const&)': [build] (.text._ZN2cv17MotionJpegCapture13retrieveFrameEiRKNS_12_OutputArrayE+0x94): undefined reference to `cv::imdecode(cv::_InputArray const&, int)' [build] /usr/bin/ld: /usr/lib/aarch64-linux-gnu/libopencv_videoio.a(cap_dc1394_v2.cpp.o): in function `CvDC1394::~CvDC1394()': [build] (.text._ZN8CvDC1394D2Ev+0xc): undefined reference to `dc1394_free'上文中错误如何解决
10-31
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值