[英]beginner GNU Makefile Error
This is my first, attempt at a, Makefile after necessity from a previous post . 这是我从上一篇帖子的必要性之后第一次尝试Makefile。
Anyway here's the code 无论如何这里是代码
SortLab.exe : SelectionSort.o Main.o
g++ -o $@ $^
SelectionSort.o : SelectionSort.cpp SelectionSort.h
Main.o : Main.cpp
#-------------------------------------------------------------
run: SortLab.exe
./SortLab.exe
clean:
rm -f *.o
rm -f *.exe
build: clean SortLab.exe
%.o: %.cpp
g++ -c $<
I intend to have SelectionSort.cpp
& SelectionSort.h
form an object file, and Main.cpp
to form its own object file. 我打算让
SelectionSort.cpp
和SelectionSort.h
形成一个目标文件,并将Main.cpp
形成自己的目标文件。 Then finally create an executable. 最后创建一个可执行文件。
Main.cpp
depends on SelectionSort.cpp
, where do I go wrong? Main.cpp
取决于SelectionSort.cpp
,我在哪里出错?
Also where can I find what the different GNU
commands mean, -o
-c
and such 另外在哪里可以找到不同的
GNU
命令的含义, -o
-c
等
%.o: %.cpp
rule yourself, Make knows how to compile C++. %.o: %.cpp
规则,Make知道如何编译C ++。 Main.o : Main.cpp SelectionSort.h
. Main.o : Main.cpp SelectionSort.h
。 build
shouldn't depend on clean
, it defeats one of Make's main features (selectively recompilation when files have changed). build
不应该依赖clean
,它会破坏Make的主要功能之一(当文件发生变化时有选择地重新编译)。 build
the first target, you can run Make without a target to get a full compile. build
作为第一个目标,则可以在没有目标的情况下运行Make以获得完整的编译。 It's customary to call the main target all
. all
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.