关于apue的静态库
时间:2011-12-23
来源:互联网
大家好,我在redhat上面编译好了《UNIX环境高级编程(第二版)》的源码,并且把lib/libapue.a拷贝到了/usr/lib。但是
在使用其中一个例子名为“cleanup”程序的时候,链接出错了,具体命令如下:
gcc -o test cleanup.c -lapue
系统提示:
/tmp/ccSjphRZ.o(.text+0x43): In function `thr_fn1':
: undefined reference to `_pthread_cleanup_push'
/tmp/ccSjphRZ.o(.text+0x5c): In function `thr_fn1':
: undefined reference to `_pthread_cleanup_push'
/tmp/ccSjphRZ.o(.text+0x85): In function `thr_fn1':
: undefined reference to `_pthread_cleanup_pop'
/tmp/ccSjphRZ.o(.text+0x96): In function `thr_fn1':
: undefined reference to `_pthread_cleanup_pop'
/tmp/ccSjphRZ.o(.text+0xcc): In function `thr_fn2':
: undefined reference to `_pthread_cleanup_push'
/tmp/ccSjphRZ.o(.text+0xe5): In function `thr_fn2':
: undefined reference to `_pthread_cleanup_push'
/tmp/ccSjphRZ.o(.text+0x116): In function `thr_fn2':
: undefined reference to `_pthread_cleanup_pop'
/tmp/ccSjphRZ.o(.text+0x127): In function `thr_fn2':
: undefined reference to `_pthread_cleanup_pop'
/tmp/ccSjphRZ.o(.text+0x156): In function `main':
: undefined reference to `pthread_create'
/tmp/ccSjphRZ.o(.text+0x193): In function `main':
: undefined reference to `pthread_create'
/tmp/ccSjphRZ.o(.text+0x1cd): In function `main':
: undefined reference to `pthread_join'
/tmp/ccSjphRZ.o(.text+0x21a): In function `main':
: undefined reference to `pthread_join'
请问为什么系统找不到/usr/lib/libapue.a呢?
谢谢!
在使用其中一个例子名为“cleanup”程序的时候,链接出错了,具体命令如下:
gcc -o test cleanup.c -lapue
系统提示:
/tmp/ccSjphRZ.o(.text+0x43): In function `thr_fn1':
: undefined reference to `_pthread_cleanup_push'
/tmp/ccSjphRZ.o(.text+0x5c): In function `thr_fn1':
: undefined reference to `_pthread_cleanup_push'
/tmp/ccSjphRZ.o(.text+0x85): In function `thr_fn1':
: undefined reference to `_pthread_cleanup_pop'
/tmp/ccSjphRZ.o(.text+0x96): In function `thr_fn1':
: undefined reference to `_pthread_cleanup_pop'
/tmp/ccSjphRZ.o(.text+0xcc): In function `thr_fn2':
: undefined reference to `_pthread_cleanup_push'
/tmp/ccSjphRZ.o(.text+0xe5): In function `thr_fn2':
: undefined reference to `_pthread_cleanup_push'
/tmp/ccSjphRZ.o(.text+0x116): In function `thr_fn2':
: undefined reference to `_pthread_cleanup_pop'
/tmp/ccSjphRZ.o(.text+0x127): In function `thr_fn2':
: undefined reference to `_pthread_cleanup_pop'
/tmp/ccSjphRZ.o(.text+0x156): In function `main':
: undefined reference to `pthread_create'
/tmp/ccSjphRZ.o(.text+0x193): In function `main':
: undefined reference to `pthread_create'
/tmp/ccSjphRZ.o(.text+0x1cd): In function `main':
: undefined reference to `pthread_join'
/tmp/ccSjphRZ.o(.text+0x21a): In function `main':
: undefined reference to `pthread_join'
请问为什么系统找不到/usr/lib/libapue.a呢?
谢谢!
作者: chennut0802 发布时间: 2011-12-23
另外请问我用这个Makefile:
CXX = gcc
CXXFLAGS = -g -Wall
INCLUDE = -I./
LIB = -lapue -lpthread
LIBS =
SRC_PATH = ./
SRCS := $(wildcard $(SRC_PATH)/*.c)
OBJS := $(patsubst %.c, %.d.o, $(SRCS))
TARGET = ./mainTest
%.d.d : %.c
@set -e; rm -f $@; \
$(CXX) -MM $(CXXFLAGS) $(INCLUDE) $< > $@.$$$$; \
sed 's,.*\.o[ ]*:,$*.o $@ :,g'< $@.$$$$ > $@; \
rm -f $@.$$$$
$(CXX) $(CXXFLAGS) $(INCLUDE) -c -o $*.d.o $<
$(TARGET):$(OBJS)
$(CXX) -o $(TARGET) $(OBJS) $(LIB)
include $(SRCS:.c/=.d.d)
.PHONY:clean
clean:
rm -f ./src/*.r.o $(TARGET) ./src/*.d.d ./tinyxml/src/*.d.o ./tin
执行make之后,会提示:
main.c:4: *** missing separator. Stop.
CXX = gcc
CXXFLAGS = -g -Wall
INCLUDE = -I./
LIB = -lapue -lpthread
LIBS =
SRC_PATH = ./
SRCS := $(wildcard $(SRC_PATH)/*.c)
OBJS := $(patsubst %.c, %.d.o, $(SRCS))
TARGET = ./mainTest
%.d.d : %.c
@set -e; rm -f $@; \
$(CXX) -MM $(CXXFLAGS) $(INCLUDE) $< > $@.$$$$; \
sed 's,.*\.o[ ]*:,$*.o $@ :,g'< $@.$$$$ > $@; \
rm -f $@.$$$$
$(CXX) $(CXXFLAGS) $(INCLUDE) -c -o $*.d.o $<
$(TARGET):$(OBJS)
$(CXX) -o $(TARGET) $(OBJS) $(LIB)
include $(SRCS:.c/=.d.d)
.PHONY:clean
clean:
rm -f ./src/*.r.o $(TARGET) ./src/*.d.d ./tinyxml/src/*.d.o ./tin
执行make之后,会提示:
main.c:4: *** missing separator. Stop.
作者: chennut0802 发布时间: 2011-12-23
gcc -o test cleanup.c -lapue -lpthread
作者: zmlovelx 发布时间: 2011-12-23
请问学过《UNIX环境高级编程(第二版)》的朋友,libapue.a不包括libpthread的内容吗?
作者: chennut0802 发布时间: 2011-12-23
加上-lpthread
作者: icechenbing 发布时间: 2011-12-23
-lpthread
编译时连接pthread库,实现多线程需要用到这个库里的函数。
编译时连接pthread库,实现多线程需要用到这个库里的函数。
作者: liuchao35758600 发布时间: 2011-12-23
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28