makefile 运行出错,请指导
应该是文件包含的方法除了问题,请问应该怎么写
makefile文件名称为makefile,运行后提示:
make: *** No rule to make target `main.cpp', needed by `main.o'. Stop.
将文件放在/usr/src/code下面,其中包含:
include
------- file.h
src
-------man.cpp(#include "file.h",file.cpp(#include "file.h",
nakefile为
object = main.o file.o
inlcude = -I“/usr/src/code/maketest/include/*.h"
src = -I”/usr/src/code/maketest/src/*.cpp"
execute(object)
g++ -o execute $(object)
main.o:main.cpp
g++ -c (inlcude) $(src) main.cpp $
file.o:file.cpp file.h
g++ -c $(inlcude) $(src) file.cpp
#clean:
#rm execute $(object)
请问是出了什么问题,请指导,谢谢!!!
------解决方案--------------------
试试这个:
inlcude = -I"/usr/src/code/maketest/include/*.h"
src = -I"/usr/src/code/maketest/src/*.cpp"
COMPILE=g++ $(inlcude) $(src) -c
MAKEEXE=g++
EXE=execname
object = main.o file.o
all: $(EXE)
$(EXE): $(object)
$(MAKEEXE) $(object) -o $(EXE)
main.o: main.cpp
$(COMPILE) main.cpp
file.o: file.h file.cpp
$(COMPILE) file.cpp
clean:
rm -f *.o core $(EXE) $(object)
------解决方案--------------------
试试这个
Python code
INCLUDE=-I"./include/"
CC=g++
COMPILE=$(CC) $(INCLUDE)
OBJS=main.o file.o
main : main.o file.o
file.o: ./src/file.cpp
$(COMPILE) ./src/file.cpp -c
main.o: ./src/main.cpp
$(COMPILE) ./src/main.cpp -c