日期:2014-05-16  浏览次数:20589 次

关于 makefile 的问题
我写的makefile文件如下,但执行 make 时,仅仅执行了第一个命令,
g++ -fPIC -c POOL_Memory_Linux.cpp ,

并没有像我希望的那样接着执行 g++ -fPIC -c OBJ_Queue_Linux.cpp

请朋友们帮忙,问题在哪里呢?

POOL_Memory_Linux.o : POOL_Memory_Linux.cpp
g++ -fPIC -c POOL_Memory_Linux.cpp
OBJ_Queue_Linux.o : OBJ_Queue_Linux.cpp  OBJ_Queue_Linux.h
g++ -fPIC -c OBJ_Queue_Linux.cpp

------解决方案--------------------
try this makefile


ALL: POOL_Memory_Linux.o OBJ_Queue_Linux.o

POOL_Memory_Linux.o : POOL_Memory_Linux.cpp
g++ -fPIC -c POOL_Memory_Linux.cpp

OBJ_Queue_Linux.o : OBJ_Queue_Linux.cpp  OBJ_Queue_Linux.h
g++ -fPIC -c OBJ_Queue_Linux.cpp

------解决方案--------------------
makefile 执行完第一个目标就会退出了。
所以楼上先让你定义一个目标all,依赖于你真正的两个目标文件,这样你那两个文件就都能编译了