我想創建一個支持posix信號量的makefile。 這就是我這麼遠:用pthread創建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 [email protected]
include depends
depends:
$(CC) -MM $(OBJECTS:.o=.c) > depends
clean:
rm ./$(TARGET) *.o
出於某種原因,我得到「未定義的引用」爲所有呼叫semaphore.h中的API函數。
這可能是不相關的prolem,但你編譯和鏈接時,需要'-pthread' ,所以你應該把它添加到'CFLAGS'中。 – Idelic 2013-03-12 20:39:49