CODEBLOCKS 编译 pthread 引发错误
2009-07-20 16:00
218 查看
刚接触 CODEBLOCKS 在fedora9 下配置好环境后,复制了书上的一段线程应用代码。遭遇两个迷惑问题。未解决。
1.开始编译,提示pthread_create 未定义(用到:res = pthread_create(&thread[no], NULL, thrd_func, (void*)no);)。
上网原因:问题原因: pthread 库不是 Linux 系统默认的库,连接时需要使用静态库 libpthread.a,所以在使用pthread_create()创建线程,以及调用 pthread_atfork()函数建立fork处理程序时,需要链接该库。
于是,在CODEBLOCKS 链接器设置项中添加libpthread.a,查找到该文件在/usr/bin/lib 中(注不同环境路径可能有异)。
2.再次编译。未定义的问题解决了,但紧接着更大的问题 来了。
debug Information:
/usr/lib/libpthread.a(pthread_create.o)||In function `pthread_create':|
(.text+0xa2f)||undefined reference to `_dl_stack_flags'|
/usr/lib/libpthread.a(pthread_create.o)||In function `pthread_create':|
(.text+0xbe5)||undefined reference to `_dl_stack_flags'|
/usr/lib/libpthread.a(ptw-pause.o)||In function `__pause_nocancel':|
(.text+0x18)||undefined reference to `__syscall_error'|
/usr/lib/libpthread.a(ptw-pause.o)||In function `__pause_nocancel':|
(.text+0x3b)||undefined reference to `__syscall_error'|
/usr/lib/libpthread.a(init.o)||In function `__pthread_initialize_minimal':|
(.text+0x1c)||undefined reference to `__libc_setup_tls'|
/usr/lib/libpthread.a(init.o)||In function `__pthread_initialize_minimal':|
(.text+0x236)||undefined reference to `_dl_init_static_tls'|
/usr/lib/libpthread.a(init.o)||In function `__pthread_initialize_minimal':|
(.text+0x240)||undefined reference to `_dl_wait_lookup_done'|
/usr/lib/libpthread.a(ptw-read.o)||In function `__read_nocancel':|
(.text+0x26)||undefined reference to `__syscall_error'|
/usr/lib/libpthread.a(ptw-read.o)||In function `__read_nocancel':|
(.text+0x56)||undefined reference to `__syscall_error'|
/usr/lib/libpthread.a(ptw-open.o)||In function `__open_nocancel':|
(.text+0x26)||undefined reference to `__syscall_error'|
/usr/lib/libpthread.a(ptw-open.o)||In function `__open_nocancel':|
(.text+0x56)||undefined reference to `__syscall_error'|
/usr/lib/libpthread.a(sigaction.o)||In function `__libc_sigaction':|
(.text+0x46)||undefined reference to `_dl_sysinfo_dso'|
||=== 已完成构建: 12 个错误, 0 个警告 ===|
看到这些就晕菜了。那位前辈能指点迷津。感谢。
文件有预定#include <pthread.h>
相关文章推荐
- linux 编译过程中acx_pthread.m4类错误解决办法
- 两则const的使用引发的编译错误
- 验证参数传递引发的Java编译错误“No enclosing instance of type XXX is accessible" 及匿名内部类
- Android中的 Multiple dex files define 编译错误引发的思考
- 在liunx编译C语言程序出现Undefined reference to pthread_create in Linux 错误*
- eclipse编译openwrt应用程序报Type undefined reference to `pthread_create'错误解决方法
- CodeBlocks常见编译错误(to be updated)
- 一个编译错误引发的对default构造函数的调用时机的探讨
- linux下编译复数类型引发的错误:expected unqualified-id before '(' token
- 字符集引发的编译错误
- linux下编译复数类型引发的错误:expected unqualified-id before '(' token
- 字符集引发的编译错误
- 一个VC编译错误引发的对显示类型转换的思考(static_cast、dynamic_cast和const_cast)
- 项目引用不当,可能引发编译错误
- cocos2d-x-2.2中编译cocos2d-win32.vc2010 C1083 pthread.h No such file or director错误的解决办法
- [ARM]【编译】【实践】 - 浮点编译选项NEON引发的Skia的库Illegal instruction运行错误和解决办法
- 不正确编译引发内存错误
- c编译错误--error:stray \357 in program及其引发的字符编码概述
- coc 4000 os2d-x-2.2中编译cocos2d-win32.vc2010.sln出现:C1083 pthread.h No such file or director错误的解决办法
- 编译错误----undefined reference to 'pthread_create'问题解决