c++程序在Ubuntu 13.10上链接mongodb报错
2013-10-21 12:58
204 查看
在最新的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
其实只要把-lpthread换成-pthread就好了。
问题就是-lpthread和-pthread区别是什么? 参考话题:
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.
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
其实只要把-lpthread换成-pthread就好了。
问题就是-lpthread和-pthread区别是什么? 参考话题:
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.
相关文章推荐
- 编写简单的连接MongoDB数据库C++程序 && 解决编译C++程序时链接MongoDB动态库失败的问题
- 编写简单的连接MongoDB数据库C++程序 && 解决编译C++程序时链接MongoDB动态库失败的问题
- 我的菜鸟路,第一次在ubuntu 13.10系统上运行c++程序
- 编写简单的连接MongoDB数据库C++程序 && 解决编译C++程序时链接MongoDB动态库失败的问题
- cmakelist操作之如何在c/c++程序中链接第三方库
- C/C++程序编译流程解析(预处理->编译->汇编->链接)
- C++调用Fortran程序----动态链接方式
- Ubuntu下程序的编译和链接过程和openCV的makefile文件
- ubuntu16 配置vscode 编译c++程序
- c/c++使用VS2013连接MySQL与ubuntu下c链接mysql
- [Linux-C++] Ubuntu上程序调用静态库文件
- Linux下C++程序链接boost库
- 在Ubuntu中使用sublime text编译并运行C/C++程序
- ubuntu13.10 编译时 关于链接xlib 库阶段出错的问题解决
- Ubuntu13.10 下VMware(10.0.1) 网络无法链接
- 深度剖析一个典型的C/C++程序的编译、链接以及执行的过程
- Ubuntu下在Eclipse IDE for C/C++ Developers中如何运行C语言的GTK程序?(已解决)
- Ubuntu下sqlite3的配置与使用(以后会说到Ubuntu下C++数据库应用开发程序(窗体程序))
- ubuntu下c++链接数据库
- Ubuntu 12.04下在Eclipse IDE for C/C++ Developers中运行C语言的GTK程序