Apr28

【原创】C++程序静态链接编译log4cplus的问题小记

Author: leeon  Click: 13229   Date: 2012.04.28 @ 10:38:08 am Category: Linux C/C++编程

今天将log4cplus引入自己的程序,由于log4cplus需要线程库的支持,在静态编译的时候加上了-lpthread,但是始终在编译的时候提示找不到线程函数:


liblog4cplus.a(socketappender.o): In function `log4cplus::thread::PthreadMutexAttr::set_type(log4cplus::thread::Mutex::Type)':
../include/log4cplus/helpers/syncprims-pthreads.h:80: undefined reference to `pthread_mutexattr_settype'
liblog4cplus.a(socketappender.o): In function `~PthreadMutexAttr':
../include/log4cplus/helpers/syncprims-pthreads.h:58: undefined reference to `pthread_mutexattr_destroy'
liblog4cplus.a(socketappender.o): In function `ManualResetEvent':
../include/log4cplus/helpers/syncprims-pthreads.h:200: undefined reference to `pthread_cond_init'
liblog4cplus.a(socketappender.o): In function `~PthreadMutexAttr':
../include/log4cplus/helpers/syncprims-pthreads.h:58: undefined reference to `pthread_mutexattr_destroy'
liblog4cplus.a(socketappender.o): In function `~ManualResetEvent':
../include/log4cplus/helpers/syncprims-pthreads.h:210: undefined reference to `pthread_cond_destroy'
../include/log4cplus/helpers/syncprims-pthreads.h:210: undefined reference to `pthread_cond_destroy'
liblog4cplus.a(socketappender.o): In function `log4cplus::thread::ManualResetEvent::timed_wait(unsigned long) const':
../include/log4cplus/helpers/syncprims-pthreads.h:272: undefined reference to `pthread_cond_timedwait'

于是搜索发现必须在编译的时候加上"-pthread" 才能正常编译通过。

附上g++中-pthread和-lpthread的区别说明文章:

http://blog.chinaunix.net/uid-25909722-id-3026989.html

http://chaoslawful.iteye.com/blog/568602

http://kasicass.blog.163.com/blog/static/395619200992410313759/



TAG:   pthread log4cplus linux

    评论
    • 提交

    分类

    标签

    归档

    最新评论

    Abyss在00:04:28评论了
    Linux中ramdisk,tmpfs,ramfs的介绍与性能测试
    shallwe99在10:21:17评论了
    【原创】如何在微信小程序开发中正确的使用vant ui组件
    默一在09:04:53评论了
    Berkeley DB 由浅入深【转自架构师杨建】
    Memory在14:09:22评论了
    【原创】最佳PHP框架选择(phalcon,yaf,laravel,thinkphp,yii)
    leo在17:57:04评论了
    shell中使用while循环ssh的注意事项

    我看过的书

    链接

    其他

    访问本站种子 本站平均热度:8823 c° 本站链接数:1 个 本站标签数:464 个 本站被评论次数:94 次