问题描述
我是pretty新Makefile文件C.我想弄清楚,我会把-lpthread在我的makefile文件,所以我可以实现我的C程序POSIX线程。下面是我的Makefile,在此先感谢。
CFLAGS = -g -Wall
LDFLAGS =
CC = GCC
LD = GCCTARG1 =计算
OBJS1 = calc.o
$(TARG1):$(OBJS1)
$(LD)$(LDFLAGS)$(OBJS1)-o $(TARG1)
清洁:
室射频$(TARG1)$(OBJS1)
我会建议不使用 -l 。相反,给GCC
-pthread
同时在CFLAGS和LDFLAGS变量。这将确保preprocessor定义是在编译过程中正确设置,它将链接正确的库。
在假定的GCC。如果使用英特尔的icc或LLVM检查正确的参数。
I'm pretty new to Makefiles in C. I am trying to figure out where I would put -lpthread in my makefile so I can implement posix threads in my C program. Below is my Makefile, thanks in advance.
CFLAGS = -g -Wall
LDFLAGS =
CC = gcc
LD = gcc
TARG1 = calc
OBJS1 = calc.o
$(TARG1): $(OBJS1)
$(LD) $(LDFLAGS) $(OBJS1) -o $(TARG1)
clean:
rm -rf $(TARG1) $(OBJS1)
I would recommend not using -l
. Instead give GCC -pthread
on both the CFLAGS and LDFLAGS variables. This will make sure that preprocessor defines are properly set during the compile and it will link the correct libraries.
This assumes GCC of course. If using Intel icc or LLVM check for the right parameters.
这篇关于用C的Makefile -lpthread的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!