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
LDFLAGSis 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 andmakewill 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
CFLAGSin my environment to-O2 -Wall, then if I typemake hellowith 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 inLDFLAGSto the command line.Makefiles can explicitly override both
LDFLAGSandCFLAGS.DLDFLAGSon 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 ifLDFLAGSis set - read the Makefile to find out for sure.