gpt4 book ai didi

gcc - 将 boost 版本从 1.52 切换到 1.53 后与 GCC 链接失败

转载 作者:行者123 更新时间:2023-12-03 07:06:06 26 4
gpt4 key购买 nike

将 boost 库从版本 1.52 升级到 1.53 后,在 Linux 下使用 GCC 构建时出现以下链接器错误。相同的应用程序可以在 Windows 下使用 VC++10 和 boost 1.53 构建良好。

Invoking: GCC C++ Linker
g++ -L"/home/robert/boost_1_53_0/stage/lib" -L/usr/lib -o "MyApp" ./myObjectFile.o -lboost_log_setup-mt-s -lboost_log-mt-s -lboost_thread-mt-s -lboost_system-mt-s -lboost_regex-mt-s -lcryptopp -lboost_date_time-mt-s -lpthread -ldl -lboost_filesystem-mt-s
/home/robert/boost_1_53_0/stage/lib/libboost_thread-mt-s.a(thread.o): In function `boost::this_thread::hiden::sleep_for(timespec const&)':
thread.cpp:(.text+0xc10): undefined reference to `clock_gettime'
/home/robert/boost_1_53_0/stage/lib/libboost_thread-mt-s.a(thread.o): In function `boost::this_thread::hiden::sleep_until(timespec const&)':
thread.cpp:(.text+0x1425): undefined reference to `clock_gettime'
thread.cpp:(.text+0x14cd): undefined reference to `clock_gettime'
thread.cpp:(.text+0x159c): undefined reference to `clock_gettime'
thread.cpp:(.text+0x1684): undefined reference to `clock_gettime'
/home/robert/boost_1_53_0/stage/lib/libboost_thread-mt-s.a(thread.o):thread.cpp:(.text+0x176e): more undefined references to `clock_gettime' follow
collect2: error: ld returned 1 exit status

我像这样构建了 boost 库:

./bootstrap.sh --with-toolset=gcc
./b2 --layout=tagged variant=debug,release link=static runtime-link=static cxxflags=-std=c++0x

我的 GCC 版本是 4.7.2

最佳答案

它基本上表示链接器找不到clock_gettime函数。该函数位于 rt 库中,因此将 -lrt 添加到链接器命令行。

关于gcc - 将 boost 版本从 1.52 切换到 1.53 后与 GCC 链接失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14835605/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com