【问题标题】:How to add boost lib to Qt on linux system using qmake?如何使用 qmake 在 linux 系统上将 boost lib 添加到 Qt?
【发布时间】:2021-11-28 14:55:53
【问题描述】:

main.o:未定义对符号“pthread_condattr_setclock@@GLIBC_2.3.3”的引用

/usr/bin/ld: /usr/lib/libpthread.so.0: 添加符号时出错:命令行中缺少 DSO collect2:错误:ld 返回 1 个退出状态

【问题讨论】:

  • 您是否尝试将您的库添加到LIBS?例如,LIBS += -lboost_thread
  • 嗯,你看过错误了吗?您没有缺少提升。您缺少 pthreads。将LIBS += -lpthread 添加到项目中 :) 并开始使用 cmake 而不是可怕的 qmake 文件。至少你会得到一个广泛有用的技能和一个构建系统,它的用途不仅仅是构建 Qt 项目:)

标签: c++ linux qt boost


【解决方案1】:

首先,确保你的系统中安装了boost:

sudo apt-get install libboost-all-dev

然后在.pro 你应该添加这个:

LIBS +=-lboost_thread

已编辑:所有.pro文件

QT -= gui

CONFIG += c++11 console
CONFIG -= app_bundle


SOURCES += \
        main.cpp

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target


LIBS += -lboost_system -lboost_thread -lboost_chrono

【讨论】:

  • 我的系统(Manjaro Linux)得到了提升>
  • ‍‍‍‍link lib as system lib表示你使用ln命令?
  • 你不应该链接一些东西。
  • LIBS += -lboost_system -lboost_thread -lboost_chrono 没用 (((
  • 你不应该链接一些东西。 " 你只需要 LIBS +=-lboost_thread " 但如果你只是正常安装 boost 然后将它添加到你的项目中。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-09-15
  • 1970-01-01
  • 1970-01-01
  • 2016-09-02
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多