Search code examples
eclipseeclipse-cdt

How to let Eclipse run different make targets before Run/Debug


I am developing a C++ app in Eclipse with CDT plugin, using my own Makefile. Is there a way how to force Eclipse to run make all before I run the project but make debug before I try to debug it? I want to have the app compiled with -g switch during debugging but with -O3 when I run it, without manually rewriting the -g switch in the Makefile each time.

Thanks


Solution

  • If you have created a C++ project of type 'Makefile Project' (i.e where the user is supposed to provide his own Makefile), then you will be able to create several 'Build configurations' using the menu :

    Project > Build Configurations > Manage ...
    

    I suggest you create a 'Debug' configuration where the build settings will be 'make debug' and a 'Release' or 'Default' configuration where the build settings are 'make all'.
    This way you will be able to build and run/debug in either mode after selecting the wished configuration in menu :

    Project > Build Configurations > Set active > ...
    

    I hope this can help! Cheers.