小编use*_*932的帖子

使用 pthreads 创建 makefile

我想创建一个支持 posix 信号量的 makefile。这就是我到目前为止所得到的:

CFLAGS=-g -ansi -pedantic -Wall -Werror -D_XOPEN_SOURCE=600
LDFLAGS=-pthread 
CC=gcc
OBJECTS=MsgQueueMain.o MsgQueue.o Queue.o MyMalloc.o
TARGET=MsgQueueMain

all: $(TARGET)

$(TARGET): $(OBJECTS)
    $(CC) $(OBJECTS) -o $@

include depends

depends:
    $(CC) -MM $(OBJECTS:.o=.c) > depends

clean:
    rm ./$(TARGET) *.o
Run Code Online (Sandbox Code Playgroud)

出于某种原因,我收到了对 semaphore.h api 函数的所有调用的“未定义引用”。

c posix semaphore makefile pthreads

3
推荐指数
1
解决办法
2万
查看次数

标签 统计

c ×1

makefile ×1

posix ×1

pthreads ×1

semaphore ×1