

The result is that the C++ standard library is not available. So, the implicit rule for linking still uses CC as the linker. o file, there’s no indication from the file extension that it came from a C++ file. This is analogous to the CC variable.įlags are passed using the CCXFLAGS variable, instead of CFLAGS.

The compiler used for C++ files is set using CXX, which defaults to g++. C files (all extensions recognized by GNU Make as C++ files) into. (Note: you can also omit the definition of the CC variable, as the cc executable should point to the system-default compiler anyway.) Building C++ projectsĬompiling C++ files works similarly to compiling C files. PHONY : clean clean : rm -f $(OBJFILES) $(OUT) LDLIBS = -ldependency1 -ldependency2 $(OUT) : $(OBJFILES). CFILES = $( wildcard *.c ) OBJFILES = $(CFILES.c=.o) OUT = mainĬFLAGS = -Wall -I /additional/include/dir
