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.
what's the difference between DLDFLAGS and LDFLAGS
15.5k views Asked by user1101096 At
2
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.