UMIP程序中碰到的问题
2010-09-26 01:17
267 查看
问题一
‘PTHREAD_MUTEX_FAST_NP’ undeclared (first use in this function)查看/usr/include/pthread.h line.59
59 #ifdef __USE_GNU
60 /* For compatibility. */
61 , PTHREAD_MUTEX_FAST_NP = PTHREAD_MUTEX_TIMED_NP
62 #endif
63 };
解决方法一是添加宏定义#define __USE_GNU 1,二是使用PTHREAD_MUTEX_TIMED_NP,
三是在Makefile文件中加入-D_GNU_SOURCE
4 test_pthread.o : debug.h
5 cc -D_GNU_SOURCE -c test_pthread.c
问题二
test_pthread.o: In function `main':test_pthread.c:(.text+0x31): undefined reference to `pthread_mutexattr_init'
test_pthread.c:(.text+0x45): undefined reference to `pthread_mutexattr_settype'
test_pthread.c:(.text+0x99): undefined reference to `pthread_create'
添加头文件#include <pthread.h>
在Makefile中链接多线程库-lpthread
debug.o: In function `dbg_strdate':
debug.c:(.text+0x4d): undefined reference to `clock_gettime'
添加头文件#include <time.h>
在Makefile中添加链接库-lrt,因为在librt中实现了clock_gettime函数
2 test : $(objects)
3 cc -o test $(objects) -lpthread -lrt
问题三
lizhipeng@pp:~/test/pmip$ makecc -o pmip -lpthread -lrt
/usr/lib/gcc/i486-linux-gnu/4.4.3/../../../../lib/crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
collect2: ld returned 1 exit status
make: *** [pmip] Error 1
检查了很久,发现是Makefile写错了,漏写了一个字母b
1 ojects = main.o tqueue.o debug.o
2 pmip : $(objects)
3 cc -O2 -Wall -o pmip $(objects) -lpthread -lrt
ojects应该改为objects
以后这种问题一定要小心,查找错误时也应该明确方向
相关文章推荐
- 数据库的使用过程中由于程序方面的问题有时候会碰到重复数据,重复数据导致了数据库部分设置不能正确设置……
- Raspbian Ubuntu下安装OpenCV2.4.9的详细过程及碰到的问题和第一次程序的编译调试
- 今天写ASP.NET程序碰到2个问题
- 这两天在看微信小程序,引入模块时碰到问题
- 写多进程程序碰到的一个问题
- .Net在写托盘程序中碰到的一些问题的解决方法(无法关机/自启动等)
- 刚才写用户注册程序时碰到的怪问题
- 关于异常的疑难解答:System.BadImageFormatException (32 位上编译的.net程序,在64位上跑的时候,经常碰到的问题)
- 第一次写JSP程序可能会碰到的问题:The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Pa
- 首次在easerver发布web程序碰到几个问题
- 编写Java程序时碰到的问题
- 隐藏任务栏最大化程序窗口中碰到的一些问题及应对方法
- 老革命碰到新问题 ASP.NET程序访问UNC路径
- 碰到bind错误,主程序异常,调用处理函数退出问题
- linux中crontab定时任务启动Java程序碰到的问题
- 搭建TensorFlow中碰到的一些问题(TensorBoard不是内部或外部指令也不是可运行的程序)~
- Hibernate程序碰到的两个问题
- 写PL/SQL程序时碰到的一些问题
- 搭建TensorFlow中碰到的一些问题(TensorBoard不是内部或外部指令也不是可运行的程序)~
- 在Windows 2003上部署.NET Framework1.1开发的COM+程序碰到的问题