项目中使用了最新的boost 1.59库,并使用了最新的ARM交叉编译工具链:2014-5-9的版本,此版本的GCC编译器为4.8.3,对C++11的支持力度已经很不错了。
在没加boost库的线程库boost_thread时,编译不会有问题,但是链接时加了boost_thread、boost_system、boost_atomic等库后,出现以上错误。
百度搜索了一下,这是编译工具链的一个bug:
https://sourceware.org/bugzilla/show_bug.cgi?id=16698
http://lists.gnu.org/archive/html/bug-binutils/2014-07/msg00016.html
解决的办法:
出现这个错误是因为链接了动态库,而链接时又使用了 -s 参数,此参数是为了瘦身执行程序的,不加此参数即可编译通过,瘦身程序再通过 arm-none-linux-gnueabi-strip ./yourcode 来瘦身即可。
Invoking: Cross ARM C++ Linker
arm-none-linux-gnueabi-g++ -Os -g -Xlinker --gc-sections -L/root/workspace/boost_1_59_0/stage/lib -L/root/workspace/ACSCode/src/lib -Wl,-Map,"ACSCode.map" -s -o "ACSCode" ./src/include/thrift/concurrency/StdMonitor.o ./src/include/thrift/concurrency/StdMutex.o ./src/include/thrift/concurrency/StdThreadFactory.o ./src/include/gen-cpp/RHMPSender.o ./src/include/gen-cpp/RHMPSender_server.skeleto