[英]Makefile implicit call g++
I got a strange makefile from a tutorial on OpenGL: 我从OpenGL教程中得到了一个奇怪的makefile:
LDLIBS=-lglut -lGLEW -lGL -lm
all: cube
clean:
rm -f *.o cube
cube: shader_utils.o
.PHONY: all clean
The sources consist in 3 files: cube.cpp, shader_utils.h and shader_utils.cpp. 源包含3个文件:cube.cpp,shader_utils.h和shader_utils.cpp。 I compile the project by doing "> make cube" but I don't understand the cube target and why is g++ called.
我通过执行“> make cube来编译项目”,但我不了解多维数据集目标以及为什么调用g ++。 I didn't specify to use g++ neither to use the flag LDLIBS.
我没有指定使用g ++也不使用标志LDLIBS。
What you observed is caused by the GNU Make Implicit Rules . 您观察到的是由GNU Make隐式规则引起的。 You can even do things like below (without having
Makefile
at all): 您甚至可以执行以下操作(根本没有
Makefile
):
make -f /dev/null shader_utils.o
Those are just defaults in gmake (a default rule to make .o from .cpp or .c). 这些只是gmake中的默认值(从.cpp或.c生成.o的默认规则)。 It is seldom applicable in real life though - most likely, you'd like to provide some arguments to g++.
但是,它在现实生活中很少适用-最有可能的是,您想为g ++提供一些参数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.