$linuxjunkies
>

LDFLAGS

An environment variable that specifies linker flags passed to the linker (ld) during compilation, controlling how object files are linked into executables or libraries.

LDFLAGS is used by build systems (like Make, Autoconf, and CMake) to pass options to the linker stage of compilation. Common flags include library search paths (-L), library linking (-l), and runtime library paths (-Wl,-rpath).

For example, if you need to link against a library in a non-standard location, you might set: LDFLAGS="-L/opt/custom/lib -Wl,-rpath,/opt/custom/lib" before running ./configure or make.

This complements CFLAGS (compiler flags) and CPPFLAGS (preprocessor flags). The linker uses these flags to resolve symbols, embed library dependencies, and determine where the runtime loader should search for shared libraries.

Related terms