我有一個自定義頭文件example.h,它有幾個函數的原型。有一個.C文件example.c,我實現了其中的「include」(#include「example.h」),並且具有example.h中原型函數的實現。現在,我有另一個函數test.c調用example.h中原型並在example.c中定義的函數。C makefile錯誤
我的化妝文件如下
test: test.o
gcc -o test -g test.o
test.o: test.c example.c example.h
gcc -g -c -Wall test.c
gcc -g -c -Wall example.c
clean:
rm -f *.o test
我獲得以下消息在example.c
在文件中未定義第一次引用 符號
功能1 test.o中定義的函數
function2 test.o
功能3 test.o
function4 test.o
LD:致命的:符號引用錯誤。無輸出寫入測試
collect2:LD返回1退出狀態
*錯誤代碼1
化妝:致命錯誤:命令失敗目標'測試」
任何幫助是最讚賞。
爲什麼你不鏈接示例?你編譯它... – thang