DLDFLAGS 和 LDFLAGS 有什么区别
一个简单的问题。我在示例 Makefile 中发现了“DLDFLAGS”和“LDFLAGS”。使用的编译器是gcc。看起来它们都用于链接器。我想知道它们之间有什么区别。
A quick question. I found both "DLDFLAGS" and "LDFLAGS" in a sample Makefile. The compiler used is gcc. It looks like they are both used for linkers. I'm wondering what's the difference between them.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
LDFLAGS
通常设置为包含传递给链接器的选项(因此可能包括所需的库)。与 CFLAGS 一起,它们通常被设置为开发人员环境变量的一部分,并且 make 会了解它们,因此会主动查看它们是否已设置并将它们传递给给编译器。例如,如果我在环境中将
CFLAGS
设置为-O2 -Wall
,那么如果我在没有 Makefile 的情况下键入make hello
,make 将自动将编译器调用为gcc -O2 -Wall hello.c -o hello.o
。然后它将以类似的方式调用链接器,将LDFLAGS
中的标志添加到命令行。Makefile 可以显式覆盖
LDFLAGS
和CFLAGS
。另一方面,DLDFLAGS 不是众所周知/定义的变量,因此它可能特定于特定的 Makefile。您必须阅读 Makefile 才能了解它是如何使用的。例如,如果设置了 LDFLAGS,它可能会定义要使用的链接器标志 - 请阅读 Makefile 以进行确定。
LDFLAGS
is normally set to contain options that are passed through to the linker (so may include required libraries). Together withCFLAGS
, these are often set as part of a developers environment variables andmake
will know about them so will actively look to see if they're set and pass them through to the compiler.For example, if I set
CFLAGS
in my environment to-O2 -Wall
, then if I typemake hello
with no Makefile, make will automatically invoke the compiler asgcc -O2 -Wall hello.c -o hello.o
. Then it'll invoke the linker in a similar way, adding the flags inLDFLAGS
to the command line.Makefiles can explicitly override both
LDFLAGS
andCFLAGS
.DLDFLAGS
on the other hand is not a well known/defined variable, so it's likely to be specific to that particular Makefile. You'd have to read the Makefile to find out how it's used. It may, for example, define linker flags to use ifLDFLAGS
is set - read the Makefile to find out for sure.DLDFLAGS
不只是一个定义名为“LDFLAGS”的宏的预编译器标志吗?来自海湾合作委员会手册:
Isn't
DLDFLAGS
just a precompiler flag that defines macro named "LDFLAGS"?From gcc manual: