Search code examples
c++debuggingmakefileeclipse-cdt

How to switch between debug and release Makefiles in Eclipse CDT?


For example I have 2 Makefiles: Makefile.Debug and Makefile.Release.

I can switch between them by setting different commands in:

C/C++ Build -> Builder Settings -> build command : make -f Makefile.Debug -j4 or make -f Makefile.Release -j4, but how can I switch between two makefiles in Eclipse GUI (Like in Visual Studio debug/release configurations)?

enter image description here


Solution

  • Create two Build configurations in Eclipse, each with a different make command. Then, you can click the down arrow near the hammer in Eclipse's top bar to switch configuration.

    Detailed steps:

    1. Right click on Project, click Properties
    2. Left sidebar, click C/C++ Build
    3. Top right corner, "Manage Configurations..."
    4. Add
    5. Set "Name" and select "Existing configuration: xxxxx"
    6. Ok
    7. Ok
    8. Switch between the configurations setting what's required (in your case, under the C/C++ Build section, in the "Builder Settings" tab, select "External builder" type in the "Builder type" combo, then deselect "Use default build command" and enter yours in the "Build command" field
    9. Confirm with OK
    10. Use the hammer

    (I haven't a copy of Eclipse on this PC right now so I can't send screenshots, sorry.)