3

ブースト ライブラリをバージョン 1.52 から 1.53 にアップグレードした後、Linux で GCC を使用してビルドすると、次のリンカ エラーが発生します。同じアプリケーションは、VC++10 とブースト 1.53 を使用する Windows で正常にビルドされます。

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

次のようにブーストライブラリを構築しました。

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

私のGCCバージョンは4.7.2です

4

1 に答える 1

3

基本的には、clock_gettime関数がリンカによって見つからないことを示しています。この関数はライブラリにあるため、リンカー コマンド ラインにrt追加します。-lrt

于 2013-02-12T15:13:11.627 に答える