我想在我的項目中使用「Makefile」,它使用套接字編程。我有兩個簡單的.c文件,但他們有自己的主要功能。由於這兩個主要功能,makefile會返回一個錯誤。具有相同功能的C中的Makefile錯誤
我有server.c文件中的一個主要功能和client.c一個主要功能
ERROR
gcc server.o client.o -o output -lpthread client.o: In function
main': client.c:(.text+0x0):
main' için birden fazla tanım server.o:server.c:(.text+0x78): ilk burada tanımlanmış collect2: error: ld returned 1 exit status Makefile:4: recipe for target 'output' failed make: *** [output] Error 1
MAKEFILE
all: output
output: server.o client.o
gcc server.o client.o -o output -lpthread
server.o: server.c
gcc -c server.c
client.o: client.c
gcc -c client.c
clean:
rm *.o
謝謝:)
它不工作,對不起。錯誤是缺少分隔符? – Berkin
以'gcc'開頭的行應該以製表符開始,而不是空格。我猜你可能已經結束了空間。 :) – negacao
非常感謝。是的,我忘了將它們從空間改爲標籤。問題解決了 – Berkin