Passing C/C++ #defines to makefile

后端 未结 4 606
一向
一向 2020-12-29 20:31

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 fo

4条回答
  •  [愿得一人]
    2020-12-29 20:56

    If you're using autotools another options is to have 2 directories 'bin/debug' and 'bin/release'.

    # Simple bootstrap script.
    
    # Remove previously generated filed and call autoreconf.
    # At the end configure 2 separate builds.
    echo "Setting up Debug configuration: bin/debug"
    ../../configure CXXFLAGS="-g3 -O0 -DDEBUG=1"
    echo "Setting up Release configuration: bin/release"
    cd bin/release/
    ../../configure CXXFLAGS="-O2"
    

    Setup Eclipse. Open the project's properties (Project->Properties->C/C++ Build->Builder Settings) and set the Build Location->Build Directory to

    ${workspace_loc:/helloworld/bin/debug}
    

    Replacing 'helloworld' with your project's directory relative to the workspace (or you can supply an absolute path ${/abs/path/debug}). Do the same thing with the Release config, replacing "/debug" with "release" at the end of the path.

    This method seems like a waste of disk space, but a valid alternative to achieve completely separate builds.

提交回复
热议问题