您好,欢迎来到二三四教育网。
搜索
您的当前位置:首页[问题]在makefile中加编译参数-pthread

[问题]在makefile中加编译参数-pthread

来源:二三四教育网

问题描述

想在在makefile编译C语言程序的时候中加编译参数-pthread,不知道在makefile中该如何表示

运行环境

Ubuntu

程序源码

失败的方案

尝试一:

init.o : common.h
    cc -o init init.o common.o $(CFLAGS) -pthread

尝试二

init : init.o common.o
    cc -pthread -o init init.o common.o

报错信息

scorpion@Turing-Machine:~/OSLearn/OS-Assignment-2016/4_Linux_Progress_Control/4_5_shared_memory$ make
cc -c init.c
cc -o edit init.o common.o
common.o: In function `SemInit':
common.c:(.text+0x7f): undefined reference to `sem_open'
common.c:(.text+0xa2): undefined reference to `sem_open'
common.o: In function `SemDestroy':
common.c:(.text+0xc6): undefined reference to `sem_open'
common.c:(.text+0xe3): undefined reference to `sem_open'
common.c:(.text+0xf3): undefined reference to `sem_close'
common.c:(.text+0x102): undefined reference to `sem_unlink'
common.c:(.text+0x10e): undefined reference to `sem_close'
common.c:(.text+0x11d): undefined reference to `sem_unlink'
common.o: In function `P':
common.c:(.text+0x138): undefined reference to `sem_wait'
common.o: In function `V':
common.c:(.text+0x153): undefined reference to `sem_post'
collect2: error: ld returned 1 exit status
makefile:4: recipe for target 'edit' failed
make: *** [edit] Error 1

备注

直接在命令行中编译时成功的


QQ图片20160407121421.png

已解决

Copyright © 2019- how234.cn 版权所有 赣ICP备2023008801号-2

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务