Linux下编译时出现的错误及解决方法
2012-04-24 19:40
573 查看
Linux下编译时出现的错误及解决方法
(1)由于是Linux新手,所以现在才开始接触线程编程,照着GUN/Linux编程指南中的一个例子输入编译,结果出现如下错误:undefined reference to 'pthread_create'
undefined reference to 'pthread_join'
问题原因:
pthread 库不是 Linux 系统默认的库,连接时需要使用静态库 libpthread.a,所以在使用pthread_create()创建线程,以及调用 pthread_atfork()函数建立fork处理程序时,需要链接该库。
问题解决:
在编译中要加 -lpthread参数
gcc -o thread thread.c -lpthread
thread.c为你些的源文件,不要忘了加上头文件#include<pthread.h>
(2)出现警告:内建函数strlen不兼容的隐式声明,内建函数exit不兼容的隐式声明
问题原因:因为函数strlen在string内,exit在stdlib内。在文件中没有添加头文件 string.h和stdlib
问题解决:在文件中添加头文件 string.h和stdlib
(3)出现错误:sem_union的存储大小未知
问题原因:在新版2.6内核中关于union sem_union 这个联合体已经被注释了,需要自己写这个联合体
问题解决:在C文件中先定义
union semun {int val; struct semid_ds *buf; unsigned short *array;} sem_union;
随后编译时它就能找到预先定义好的sem_union联合体了。
相关文章推荐
- 64bit ubuntu14.04编译PlatinumKit出现的arm-linux-androideabi-g++: not found错误解决方法
- 编译PlatinumKit出现的arm-linux-androideabi-g++: not found错误解决方法
- linux下编译C++程序出现错误 “*** stack smashing detected ***, eclipse解决方法
- 在VMware上编译linux内核出现VFS: Cannot open root device "LABEL=/" or unknown-block(0,0) 错误的解决方法
- 一个windows10系统中linux子系统的编译出现“undefine reference to”错误的解决方法
- linux内核编译过程中出现两个错误的解决方法~!
- GCC-4.6.3编译linux2.6.32.12内核出现“重复的成员‘page’”错误的解决方法
- 编译出现"undefined reference to `GTK_WIDGET_REALIZED',`GTK_WIDGET_VISIBLE' "相关错误的解决方法
- 编译升级linux由2.4.20-8到2.6.10内核时,遇到的错误,以及解决方法
- VS2012 Release编译时出现 “error LNK2026: 模块对于 SAFESEH 映像是不安全的。” 错误提示的解决方法
- 添加jar包编译出现错误"XXX cannot be resolved or is not a field"解决方法
- linux 内核编译时出现scripts/sign-file.c:23:30: fatal error: openssl/opensslv.h错误的解决办法
- Ruby环境Sass编译中文出现Syntax error: Invalid GBK character错误解决方法
- VS编译中出现 inline”之后应输入“(”错误问题解决方法
- PDF编译出现错误解决的方法————————【Badboy】
- Linux下Eclipse编译时,报recompile with -fPIC错误,解决方法
- asp.net程序编译调试时偶尔出现访问被拒绝的错误的解决方法
- Linux启动网卡时出现RTNETLINK answers: File exists错误解决方法
- ubuntu 编译 Android 出现的若干错误及解决方法
- linux3.0.1内核下V4L2接口使用zc301摄像头出现segment fault错误的解决方法