我想寫一個makefile,我可以在linux和mac上使用地址消毒劑構建。這適用於我的無業遊民例如:Makefile爲Linux和Mac與地址消毒劑
CC = gcc
ASAN_FLAGS = -fsanitize=address -fno-omit-frame-pointer -Wno-format-security
ASAN_LIBS = -static-libasan
CFLAGS := -Wall -Werror --std=gnu99 -g3
LDFLAGS += -lpthread
all: hello
hello: tiny_queue.o hello.o
$(CC) -o [email protected] $(CFLAGS) $(ASAN_FLAGS) $(CURL_CFLAGS) $^ $(LDFLAGS) $(CURL_LIBS) $(ASAN_LIBS)
這部作品ubuntu/trusty64
,但無法在我的Mac與
$ make
gcc -Wall -Werror --std=gnu99 -g3 -I/opt/X11/include -c -o hello.o hello.c
gcc -o hello -Wall -Werror --std=gnu99 -g3 -fsanitize=address -fno-omit-frame-pointer -Wno-format-security tiny_queue.o hello.o -lpthread -static-libasan
clang: error: unknown argument: '-static-libasan'
make: *** [hello] Error 1
有誰知道怎麼寫了Mac和Linux兼容的makefile?
p.s.我對C很陌生,對不起,如果這個問題是超級基礎。
爲編譯器和鏈接器構建具有'-pthread'標誌的多線程代碼。 '-lpthread'不夠。 –
請參閱[AddressSanitizer](http://clang.llvm.org/docs/AddressSanitizer.html) –
這與C語言無關。 (嚴格地說,甚至不是makefile問題)。 – Olaf