[英]Required prebuild rule in generic Makefile
I'm compiling C++ code for Webots (a robotic simulator), by means of makefiles, and I'm using the generic makefile Makefile.include
Webots supplies to ease the process. 我正在通过makefiles为Webots(机器人模拟器)编译C ++代码,并且使用通用的makefile
Makefile.include
Webots提供的资源来简化此过程。
I build by own makefile, set a bunch of required variables and then call that makefile that sets all the necessary rules for compilation. 我通过自己的makefile进行构建,设置了一堆必需的变量,然后调用该makefile来设置所有必需的编译规则。 That's how it was supposed to work anyway.
无论如何,这就是应该的方式。
I'm getting the following error: 我收到以下错误:
make[1]: *** No rule to make target 'USER_PREBUILD'. Stop.
/usr/share/webots/resources/Makefile.include:503: recipe for target 'pre-build' failed
make: *** [pre-build] Error 2
And looking at the relevant line (from Makefile.include
): 并查看相关的行(来自
Makefile.include
):
$(SUPPORTED_TARGETS): post-build
USER_PREBUILD:
USER_POSTBUILD:
pre-build:
@$(MAKE) --silent USER_PREBUILD
post-build: main-build
@$(MAKE) --silent USER_POSTBUILD
$(TARGETS): pre-build
main-build: $(TARGETS)
I'm not sure if there is not a syntax error when calling make
in the pre-build
and post-build
, or if USER_PREBUILD
and USER_POSTBUILD
are supposed to be concrete files, but even if replace them with $(USER_PREBUILD)
I get *** No targets specified and no makefile found
. 我不确定在
pre-build
和post-build
调用make
时是否没有语法错误,或者USER_PREBUILD
和USER_POSTBUILD
应该是具体文件,但是即使将它们替换为$(USER_PREBUILD)
我$(USER_PREBUILD)
得到*** No targets specified and no makefile found
。 So I assume I would need to set those variables before calling the external makefile, but what exactly is the syntax if I don't have anything to be done before building? 因此,我假设我需要在调用外部makefile之前设置这些变量,但是如果在构建之前我无须做的事情,语法到底是什么呢?
Strangely, even despite these errors, the program compiles (I get the *.o, *.d and the binary on the build
folder), but it never copies the binary to the destination folder. 奇怪的是,即使出现这些错误,程序仍会编译(我在
build
文件夹中得到了* .o,*。d和二进制文件),但是它从未将二进制文件复制到目标文件夹中。
That's a bit of an odd way to have set things up in that file. 在该文件中进行设置的方法有点奇怪。
The USER_PREBUILD:
and USER_POSTBUILD:
lines have no effect and are not doing anything for anyone (at least that I'm aware of). USER_PREBUILD:
和USER_POSTBUILD:
行无效,并且对任何人都没有做任何事情(至少我知道)。
You have two choices for how to solve this problem. 您有两种选择方式来解决此问题。
You can provide empty rules for the USER_PREBUILD
and USER_POSTBUILD
targets in your makefile: 您可以在生成文件中为
USER_PREBUILD
和USER_POSTBUILD
目标提供空规则:
USER_PREBUILD USER_POSTBUILD: ;
or you can avoid even the attempt at running those targets (at the cost of an over-riding warning message from make) by using these lines: 或者您甚至可以避免使用这些行来尝试运行这些目标(以make发出的压倒性警告消息为代价):
pre-build: ;
post-build: main-build ;
in your makefile after the inclusion of Makefile.include
. 在包含
Makefile.include
之后 ,在您的makefile中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.