求教一个makefile

SKATE11 2013-11-28 09:33:31
CFLAGS := -Wall -O2

PROGS = \
mutilprocessserver \
client \

all: $(PROGS)

mutilprocessserver: mutilprocessserver.c sendReceive.o

client: client.c sendReceive.o

sendReceive.o: sendReceive.c

.PHONY : clean dist

dist : clean
tar czf 02152c.tar.gz *.

这是我原本的makefile 现在要链接一个静态库,也就是lpthread.a 怎样在这基础上修改啊
...全文
199 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
max_min_ 2013-11-29
  • 打赏
  • 举报
回复

//如果是线程库的话
mutilprocessserver: mutilprocessserver.c sendReceive.o -lpthread
//如果是自己生成的话
mutilprocessserver: mutilprocessserver.c sendReceive.o -L ./xx/xx libpthread.a
也可以像一楼那样,不过注意-L 来引导路径
SKATE11 2013-11-29
  • 打赏
  • 举报
回复
谢谢大师们的指导
ForestDB 2013-11-29
  • 打赏
  • 举报
回复
引用 6 楼 max_min_ 的回复:
[quote=引用 5 楼 ForestDB 的回复:] 我拼写错误LZ都没发现?改成 LDFLAGS = -lpthread.a 加了选项之后,它已经出现在命令行中,如下 cc -Wall -O2 -lptrhead.a mutilprocessserver.c sendReceive.o -o mutilprocessserver /usr/bin/ld: cannot find -lptrhead.a 如果LZ仔细看看上面的出错信息,就知道生效了,只是打错库了。
LDFLAGS = -lpthread 就可以了吧! 不需要后缀吧,加了后缀,貌似还要加前缀的[/quote] 版主英明。。
max_min_ 2013-11-29
  • 打赏
  • 举报
回复
引用 5 楼 ForestDB 的回复:
我拼写错误LZ都没发现?改成 LDFLAGS = -lpthread.a 加了选项之后,它已经出现在命令行中,如下 cc -Wall -O2 -lptrhead.a mutilprocessserver.c sendReceive.o -o mutilprocessserver /usr/bin/ld: cannot find -lptrhead.a 如果LZ仔细看看上面的出错信息,就知道生效了,只是打错库了。
LDFLAGS = -lpthread 就可以了吧! 不需要后缀吧,加了后缀,貌似还要加前缀的
ForestDB 2013-11-29
  • 打赏
  • 举报
回复
我拼写错误LZ都没发现?改成 LDFLAGS = -lpthread.a 加了选项之后,它已经出现在命令行中,如下 cc -Wall -O2 -lptrhead.a mutilprocessserver.c sendReceive.o -o mutilprocessserver /usr/bin/ld: cannot find -lptrhead.a 如果LZ仔细看看上面的出错信息,就知道生效了,只是打错库了。
SKATE11 2013-11-29
  • 打赏
  • 举报
回复
引用 2 楼 max_min_ 的回复:

//如果是线程库的话
mutilprocessserver: mutilprocessserver.c sendReceive.o -lpthread
//如果是自己生成的话
mutilprocessserver: mutilprocessserver.c sendReceive.o -L ./xx/xx libpthread.a
也可以像一楼那样,不过注意-L 来引导路径
嗯嗯 第一种方法可行
SKATE11 2013-11-29
  • 打赏
  • 举报
回复
引用 1 楼 ForestDB 的回复:
CFLAGS := -Wall -O2 LDFLAGS = -lptrhead.a ...
还是不行啊 报错 cc -Wall -O2 -lptrhead.a mutilprocessserver.c sendReceive.o -o mutilprocessserver mutilprocessserver.c: In function ‘main’: mutilprocessserver.c:89: warning: pointer targets in passing argument 3 of ‘accept’ differ in signedness /usr/include/sys/socket.h:214: note: expected ‘socklen_t * __restrict__’ but argument is of type ‘int *’ mutilprocessserver.c:35: warning: unused variable ‘pid’ mutilprocessserver.c: In function ‘noBlocInput’: mutilprocessserver.c:212: warning: ignoring return value of ‘gets’, declared with attribute warn_unused_result In file included from /usr/include/stdio.h:910, from sendReceive.h:1, from mutilprocessserver.c:10: In function ‘gets’, inlined from ‘noBlocInput’ at mutilprocessserver.c:212: /usr/include/bits/stdio2.h:230: warning: call to ‘__gets_warn’ declared with attribute warning: please use fgets or getline instead, gets can't specify buffer size /usr/bin/ld: cannot find -lptrhead.a collect2: ld returned 1 exit status make: *** [mutilprocessserver] 错误 1
ForestDB 2013-11-28
  • 打赏
  • 举报
回复
CFLAGS := -Wall -O2 LDFLAGS = -lptrhead.a ...

69,373

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧