Search code examples
makefileeclipse-cdt

Passing C/C++ #defines to makefile


I develop C/C++ using the Eclipse IDE. Eclipse also generates a makefile which I don't want to edit as it will simply be overwritten.

I want to use that makefile for nightly build within Hudson.

How do I pass #defines which are made in the project file of the IDE to the makefile ? (and why doesn't Eclipse already include them in the generated makefile?)

I actually had this figured out once, then accidentally overwrote it :-( But at least I know that it can be done...


Solution

  • If you are running make from the command line, use

    make CPPFLAGS=-DFOO
    

    which will add -DFOO to all compilations. See also CFLAGS, CXXFLAGS, LDFLAGS in the make manual.