runfile : file.o prog.o dir.o main.o
g++ -o runfile main.o dir.o prog.o text.o file.o
file.o : file.cpp file.h
g++ -c file.cpp
text.o : text.cpp text.h
g++ -c text.cpp
prog.o : prog.cpp prog.h
g++ -c prog.cpp
dir.o : dir.cpp dir.h
g++ -c dir.cpp
main.o : main.cpp
g++ -c main.cpp
clean:
rm *.o
每次使用g ++时,都会给我“ g ++:错误:main.o:没有这样的文件或目录”错误它给我每个像file.o一样的“:file.o:命令未找到”:file.cpp file.h
我不确定如何解决此问题。在尝试之前,我已经尝试了几种不同的方法,例如
g++ -c file.cpp
g++ -c text.cpp
g++ -c prog.cpp
g++ -c dir.cpp
g++ -c main.cpp
g++ -o runfile main.o dir.o prog.o text.o file.o
这没有用,因为它没有将h文件链接到它,也没有允许它的面向对象的部分。
我不知道它是否重要,但是file是一个抽象类,而text,prog和dir是它的子类。
我知道了。我做错了。您不能将Makefile作为./makefile运行,而必须作为make运行。