yi顽童 2014-03-19 06:35 采纳率: 0%
浏览 2728

linux 链接动态库时产生如下错误

g++ ADS_APIServer.o ../../udt/src/libudt.so ../Commlib/libCommlib.so libADS_APIServer.so -o ADS_APIServer
ADS_APIServer.o: In function soapOpenThread(void*)':
ADS_APIServer.cpp:(.text+0x8b0): undefined reference to
pthread_create'
ADS_APIServer.o: In function main':
ADS_APIServer.cpp:(.text+0xd85): undefined reference to
pthread_create'
ADS_APIServer.cpp:(.text+0xdb1): undefined reference to pthread_create'
ADS_APIServer.cpp:(.text+0xddd): undefined reference to
pthread_create'
ADS_APIServer.cpp:(.text+0xe09): undefined reference to pthread_create'
ADS_APIServer.o:ADS_APIServer.cpp:(.text+0xe38): more undefined references to
pthread_create' follow
../../udt/src/libudt.so: undefined reference to pthread_mutex_trylock'
../Commlib/libCommlib.so: undefined reference to
pthread_mutexattr_settype'
../../udt/src/libudt.so: undefined reference to pthread_key_create'
../Commlib/libCommlib.so: undefined reference to
dlsym'
../Commlib/libCommlib.so: undefined reference to dlerror'
../../udt/src/libudt.so: undefined reference to
pthread_getspecific'
../Commlib/libCommlib.so: undefined reference to pthread_mutexattr_destroy'
../Commlib/libCommlib.so: undefined reference to
pthread_mutexattr_init'
../../udt/src/libudt.so: undefined reference to pthread_key_delete'
../Commlib/libCommlib.so: undefined reference to
dlopen'
../../udt/src/libudt.so: undefined reference to pthread_setspecific'
../Commlib/libCommlib.so: undefined reference to
dlclose'
../../udt/src/libudt.so: undefined reference to `pthread_join'

  • 写回答

1条回答

  • yi顽童 2014-03-19 08:03
    关注

    自己顶下,随便结束问答,问题已解决,问题产生的原因是:
    pthread这个库不是系统库,在链接时需要在命令行指定 -lpthread 项
    dl* 则需要在命令行指定 -ldl 项

    另外在linux下执行程序时,如果需要链接动态库,下面两个命令有用
    1 echo LD_LIBRARY_PATH # 该命令查看当前的配置路径
    2 export LD_LIBRARY_PATH=.:../*:/home/.. # 添加路径,其中每个路径以“:”分隔

    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题