Editing Compiler Include (or other) Settings in Eclipse

So now I have carefully set up my compiler include paths in Eclipse to tell the GNU compiler where to find my header files:

Include Paths

Include Paths

The question is: how can I apply these settings to another project?

Copy-Paste

One of the hidden features in Eclipse is that for the ‘list’ panel settings I can copy and paste them, see “Adding Multiple Include Paths to Build Settings in Eclipse“. So I can select one or multiple lines and then paste it into the other project settings panel.

Selected mulitple include path settings

Selected multiple include path settings

Then use the usually way on your host to copy (CTRL-C on Windows) and paste (CTRL-V on Windows). As this works through the clipboard, you can paste the content to a text editor too and do further edit, then paste the result into the settings.

Editing the CDT Project File

Another way is to directly edit the project file. All the build tool settings of Eclipse CDT are stored in the .cproject file in the project root folder:

CDT cproject Eclipse File

CDT cproject Eclipse File

❗ Be careful with editing this file. If you mess up things, your project won’t work any more. Make sure that you do not have that project open in Eclipse to avoid that your file might get overwritten.

If I open that file with a text editor, it is usually easy to spot the place where the option is defined. For the case of the GNU ARM Eclipse plugins it is this:

<option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.include.paths.852737460" 
name="Include paths (-I)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.include.paths" 
useByScannerDiscovery="false" valueType="includePath">
                                    <listOptionValue builtIn="false" value=""../Sources""/>
                                    <listOptionValue builtIn="false" value=""../Project_Settings/Startup_Code""/>
 ...                                   
</option>
Include Options present in cproject file

Include Options present in cproject file

With a text editor or with a script it is now easy to change the option entries there.

Summary

Instead manually editing/adding new ‘list’ entries like the compiler include paths, it is much easier to copy-paste them directly in the option setting of the compiler settings. But I can edit the paths inside the .cproject project file too. Simply open the .cproject file with a normal text editor (or the Eclipse Editor view) and I can do any changes I want or need. And best of all: that method is not limited to include paths: I can change any settings

Happy Including 🙂

Advertisements

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.