日期:2014-05-16 浏览次数:20512 次
在最新的Ubuntu13.10上,用编译器clang3.4编译我原来的程序,出现错误:
c++ -g .private/windtunnel/code/site/builder/object/site_response.cc.o .private/windtunnel/code/site/builder/object/my_app.cc.o .private/windtunnel/code/site/builder/object/mongo_session.cc.o .private/windtunnel/code/site/builder/object/time_helper.cpp.o .private/windtunnel/code/site/builder/object/data.cc.o .private/windtunnel/code/site/builder/object/main.cpp.o .private/windtunnel/code/site/builder/object/mems.cc.o .private/windtunnel/code/site/builder/object/data_service.cc.o .private/windtunnel/code/site/builder/object/host.cc.o .private/windtunnel/code/site/builder/object/cpus.cc.o .private/windtunnel/code/site/builder/object/mongo_session_factory.cc.o .private/windtunnel/code/site/builder/object/hosts.cc.o .private/windtunnel/code/site/builder/object/site.cc.o .private/windtunnel/code/site/builder/object/host_service.cc.o .private/windtunnel/code/site/builder/object/home.cc.o -o bin/wind_tunnel -rdynamic -lpthread -lcppcms -lmongoclient -lbooster -lcryptopp -lboost_system -lboost_thread -lboost_filesystem /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libmongoclient.a(spin_lock.o): undefined reference to symbol 'pthread_yield@@GLIBC_2.2.5' /lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status
http://stackoverflow.com/questions/875789/gcc-do-i-need-d-reentrant-with-pthreads/876005#876005
https://groups.google.com/forum/#!topic/comp.programming.threads/NCEpG0EOCCY
-pthread就是 -D_REENTRANT -lpthread
`-pthread' Adds support for multithreading with the "pthreads" library. This option sets flags for both the preprocessor and linker.