Back to the index
LDADD, LDLIBS, and LIBS
In Makefiles you can often see some of the variables LDADD, LDLIBS, or LIBS. Why are three different variables needed for this?

These three variables all control which libraries are to be linked with a program.

LDADD is used by NetBSD in the bsd.prog.mk Makefile, which is used to build programs of the base distribution and some of the programs in pkgsrc.

LDLIBS is used by NetBSD in the sys.mk Makefile, which is used for implicit rules.

LDLIBS is also used by GNU Make.

LIBS is used by the GNU ./configure scripts.

So if you want to be portable, you should rely on the LIBS variable to be set by the user and set both LDADD and LDLIBS to ${LIBS}.