开发者

g++ and boost linker error on Ubuntu oneiric

开发者 https://www.devze.com 2023-04-12 19:20 出处:网络
I am getting the following errors after an upgrade.I cannot figure what is wrong with 开发者_如何学JAVAit.It should work as far as I can see.

I am getting the following errors after an upgrade. I cannot figure what is wrong with 开发者_如何学JAVAit. It should work as far as I can see.

$ make 2>&1 | head
g++ -o prog -ansi -O2 -Wall -I/usr/include/boost -L/usr/lib -lboost_program_options -lboost_thread -lstdc++ ./YYY.o ./main.o ./myClass.o
./YYY.o: In function `void boost::call_once<void (*)()>(boost::once_flag&, void (*)())':
YYY.cc:(.text._ZN5boost9call_onceIPFvvEEEvRNS_9once_flagET_[void boost::call_once<void (*)()>(boost::once_flag&, void (*)())]+0x14): undefined reference to `boost::detail::get_once_per_thread_epoch()'
YYY.cc:(.text._ZN5boost9call_onceIPFvvEEEvRNS_9once_flagET_[void boost::call_once<void (*)()>(boost::once_flag&, void (*)())]+0x2c): undefined reference to `boost::detail::once_epoch_mutex'
YYY.cc:(.text._ZN5boost9call_onceIPFvvEEEvRNS_9once_flagET_[void boost::call_once<void (*)()>(boost::once_flag&, void (*)())]+0x62): undefined reference to `boost::detail::once_epoch_mutex'
YYY.cc:(.text._ZN5boost9call_onceIPFvvEEEvRNS_9once_flagET_[void boost::call_once<void (*)()>(boost::once_flag&, void (*)())]+0x67): undefined reference to `boost::detail::once_epoch_cv'
YYY.cc:(.text._ZN5boost9call_onceIPFvvEEEvRNS_9once_flagET_[void boost::call_once<void (*)()>(boost::once_flag&, void (*)())]+0x95): undefined reference to `boost::detail::once_epoch_mutex'
YYY.cc:(.text._ZN5boost9call_onceIPFvvEEEvRNS_9once_flagET_[void boost::call_once<void (*)()>(boost::once_flag&, void (*)())]+0xa9): undefined reference to `boost::detail::once_epoch_mutex'
YYY.cc:(.text._ZN5boost9call_onceIPFvvEEEvRNS_9once_flagET_[void boost::call_once<void (*)()>(boost::once_flag&, void (*)())]+0xbd): undefined reference to `boost::detail::once_global_epoch'
YYY.cc:(.text._ZN5boost9call_onceIPFvvEEEvRNS_9once_flagET_[void boost::call_once<void (*)()>(boost::once_flag&, void (*)())]+0xc2): undefined reference to `boost::detail::once_epoch_cv'

$ ls -l /usr/lib/*boost_threa*
   0 lrwxrwxrwx 1 root root   17 Jun  3 22:30 /usr/lib/libboost_thread-mt.a -> libboost_thread.a
   0 lrwxrwxrwx 1 root root   25 Jun  3 22:30 /usr/lib/libboost_thread-mt.so -> libboost_thread.so.1.46.1
208K -rw-r--r-- 1 root root 208K Jun  3 22:30 /usr/lib/libboost_thread.a
   0 lrwxrwxrwx 1 root root   25 Jun  3 22:30 /usr/lib/libboost_thread.so -> libboost_thread.so.1.46.1
 88K -rw-r--r-- 1 root root  87K Oct 21  2010 /usr/lib/libboost_thread.so.1.42.0
100K -rw-r--r-- 1 root root  99K Jun  3 22:30 /usr/lib/libboost_thread.so.1.46.1

$ ls -ld /usr/include/boost/*thread*
4.0K drwxr-xr-x 5 root root 4.0K Oct 13 21:59 /usr/include/boost/thread/
4.0K -rw-r--r-- 1 root root  839 Jun  3 22:18 /usr/include/boost/thread.hpp


The solution involved changing the order of linkage, as per the man page. The thing is that it used to work fine with an older version of g++...

$ make
g++ -I/usr/include/boost -MM ./YYY.cc ./main.cc ./myClass.cc > buildfiles.d
g++ -ansi -O2 -Wall -I/usr/include/boost   -c -o main.o main.cc
g++ -ansi -O2 -Wall -I/usr/include/boost   -c -o myClass.o myClass.cc
g++ -o prog -ansi -O2 -Wall -I/usr/include/boost  ./YYY.o ./main.o ./myClass.o -lstdc++ -L/usr/lib -lboost_program_options -lboost_thread 
0

精彩评论

暂无评论...
验证码 换一张
取 消