我有這樣的目錄結構:的Makefile:沒有這樣的文件或目錄
- src
- /GUILayer
- /PhysicLayer
- /LogicLayer
- /Utilities
- main.cpp
- makefile
- makefile.inc
這是我當前的src
內makefile
:
include makefile.inc
DIRS = PhysicLayer LogicLayer GUILayer Utilities
OBJLIBS = PhysicLayer.a LogicLayer.a GUILayer.a Utilities.a
EXTERNOBJ = $(foreach path, $(DIRS), $(wildcard $(path)/*.o))
TARGETS = main.cpp
EXE = main
all : $(EXE)
%.a :
-for d in $(DIRS); do (cd $$d; $(MAKE)); done
ar cr [email protected] $^
main: $(OBJLIBS)
$(ECHO) $(CC) $(CFLAGS) $(EXTERNOBJ) $(OBJLIBS) -o [email protected] $(TARGETS)
$(CC) $(CFLAGS) $(EXTERNOBJ) $(OBJLIBS) -o [email protected] $(TARGETS)
clean :
-$(RM) -f ./main
find . -name "*.o" -type f -print | xargs /bin/rm -f
find . -name "*.a" -type f -print | xargs /bin/rm -f
的文件夾內的文件生成。 o就好了,但main
根本不會生成。 這是從終端的輸出:
g++ -Wall -pedantic -pedantic-errors -g -ggdb PhysicLayer.a LogicLayer.a GUILayer.a Utilities.a -o main main.cpp
/tmp/ccA3VJed.o: In function `main':
/home/user/Desktop/project/src/main.cpp:14: undefined reference to `Indexador::Indexador()'
/home/user/Desktop/project/src/main.cpp:19: undefined reference to `Indexador::indexar(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/home/user/Desktop/project/src/main.cpp:38: undefined reference to `Indexador::~Indexador()'
/home/user/Desktop/project/src/main.cpp:38: undefined reference to `Indexador::~Indexador()'
collect2: ld returned 1 exit status
make: *** [main] Error 1
你應該提供發行實際編譯命令。你的makefile會迴應其他的東西,這隻會讓事情變得混亂。您打印的命令實際上沒有要編譯的文件。 – juanchopanza 2013-04-26 05:44:57
你看,這個'g ++ -Wall -pedantic -pedantic-errors -g -ggdb -o Bloque.o'什麼也沒做。你需要一些輸入文件,大概你需要在某處添加一個'-c'來編譯一個目標文件,而不是一個可執行文件。它應該是這個樣子'G ++ -c -Wall -pedantic -pedantic-錯誤-g -ggdb Bloque.cpp -o Bloque.o' – juanchopanza 2013-04-26 06:24:26
@juanchopanza,你能再次讀取原來的職位?我已經更新了它。謝謝! – 2013-04-26 06:46:47