首页 > 在makefile中加编译参数-pthread

在makefile中加编译参数-pthread

问题描述

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

运行环境

Ubuntu

程序源码

Github: 4_5_shared_memory

失败的方案

尝试一:

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

报错信息

备注

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


你得在编译edit那个目标下面加-pthread啊,你加到init去,make默认把Makefile的第一个目标作为档次执行的目标,于是编译目标edit调用的cc -o edit $(objects)没有-pthread啊。


试试 xmake 。。

加上

add_ldflags("pthread")

就行了。。。。


makefile 同时生成多个可执行文件

【热门文章】
【热门文章】