Build Configurations in Eclipse

Eclipse based IDE’s have a powerful feature to make ‘variants’ of the same projects: Build Configurations. Build configurations are a powerful thing in Eclipse: they allow me to make ‘variants’ of a project. The project will share the common things, and I can simply tweak things one way or the other for example to produce a ‘release’ or a ‘debug’ binary of my application without duplicate the project.

Build configurations are manged through either the context menu on the project or with the top menu:

Eclipse Project Build Configuration

Eclipse Project Build Configuration

I’m showing in this post screenshots from NXP Kinetis Design Studio V3.2.0, but things are applicable to pretty much any Eclipse based IDE.

💡 Build configurations only apply to the build settings, and not to the debug settings.

With the ‘Manage’ option I can manage my configurations:

Managing Build Configuration Dialog

Managing Build Configuration Dialog

For example I can add a ‘Release’ configuration with the ‘New’ button:

💡 See “Debug vs. Release?” for more thoughts on that topic.

Creating New Configuration

Creating New Configuration

I give a name and an optional description. I usually ‘clone’ from an existing configuration. That way I get a new configuration with a good starting point.

One configuration is always active, and the ‘manage’ dialog can be used to change the active configuration:

Active Build Configuration

Active Build Configuration

The active build configuration shows up in the list of configuration e.g. under the build ‘hammer’:

Active Build

Active Build

So how can I specify settings for a configuration? For this there configuration area in the project settings:

Configurations in Project Settings

Configurations in Project Settings

There is a button to manage the configurations, and a drop down to select the configuration which I want to affect. There is as well one item in the list as [All Configurations]: when using that item, changes are ‘pushed’ to all configurations.

For example I can set a different compiler optimization for the Release configuration:

Release Configuration with high optimimzation

Release Configuration with high optimimzation

💡 When using multiple configurations, always check to which configuration you are making the changes.

The configuration name is used as the name for the output folder name:

Configuration Name in Output Folder

Configuration Name in Output Folder

That way for each configuration separate binaries are built.

Summary

Eclipse configurations are a great way to make different variants of projects. A new configuration can be cloned from an existing one, and then tweaked for example to build a release binary or to use custom build settings.

Happy Building 🙂

Advertisements

16 thoughts on “Build Configurations in Eclipse

  1. This comes in handy for more than Debug and Release. I’ve written code that builds for multiple Arduino boards using ToddlerEclipse. I’ve used it to debug code on my desktop that is then targeted for the Raspberry Pi. That’s using Eclipse Mars.

    Like

  2. Pingback: GNU Code Coverage on Embedded Target with Eclipse Neon and ARM gcc 5 | MCU on Eclipse

  3. Hello,
    I am playing around in S32 Design Studio IDE (still Eclipse based) for a couple of days.
    This post is very useful.
    But I still don’t understand how to go further.
    I have my Release build configured. Now I am try to run the project in Release mode.
    For that I make a new “Run Configuration”. After setting up, I still have issues launching the .elf file.
    I already checked if the proper elf is loaded. What else should I check?
    Some guide will be really helpful.
    Thank you !

    Like

  4. so I’m trying to get this to also include (or in Eclipse parlance “exclude”) particular .c files (or any other resource I should think) in each configuration. This is using KDS 3.2

    If I right click on a .c file, there is an entry “Resource Configurations->exclude from build… where it presents you a list of configurations (which are created as you note above) with checkboxes so you select which configuration to exclude the build of this resource on.

    When it excludes the resource from a configuration, it shows it in the explorer window as grey with a slashed icon (indicating not being used). This is what I expect.

    The problem I’m having with it is that even when I set the active configuration to the second one, the display (and compiles) all looks like they use only the first configuration (what would be your default). Every place that tells me what configuration is in use agrees with each other, just not project explorer (it never changes what it has greyed out).

    Not working as I expect it to but then again, maybe I’m expecting the wrong thing.

    Like

  5. Interesting…. I’ve created a third configuration here assuming the default one is “special” and assigned the .c files that should have been in that configuration to the new one.

    So now none of the conditional ones are excluded from any profile according to the project explorer view. Basically the behaviour is that everything that is showing excluded in the default “debug” configuration actually is excluded but if it’s excluded in any other configuration, it is not excluded. so this first configuration is somehow special or there is something that can’t tell the difference.

    This is on KDS 3.2.0

    Like

    • One thought (about something fooled me sometimes): do a Refresh/F5 in that Project Explorer view, maybe this helps.
      Other than that: open the .cproject with a text editor and search for that file: I guess something is wrong in there, and you might be able to fix it with the text editor?

      Erich

      Like

      • got this to work be deleting the default debug configuration basically….

        Chalk it up to a confused KDS — works fine now.

        thanx

        Like

  6. hello Eric,
    Thanks for sharring this intresting article for me at least.
    However what am i really searching is a brief explanation about c/c++ eclipses tools used to set
    the build configurations and i can not find something on it.
    Please If you have any good source to propose share it.
    Thanks,
    Nick

    Like

    • Hi Nick,
      not sure what you mean with ‘c/c++ eclipse tools to set the build configuration’? In Ecipse you can change/create/delete the build configurations as shown with this article. Or what I’m missing?
      Otherwise you could use XML parsing/creating tools to modify the .cproject file?

      Like

What do you think?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.