Eclipse : add automatic include folder

Eclipse is a  C, C++, Java and other programming language editor. I use this editor to create program with C/C++. When I use this editor, I have a problem to add include directory to eclipse editor. Right click at your project folder in Eclipse and choose Properties (Alt+Enter).  Locate and click Paths and Symbols menu. This is a picture to add include directory to Eclipse :

Usually I use add button to add include directory location in Eclipse. When I want to add multiple directory, we must manually add that directory one by one because Eclipse dont have include directory with subdirectory :(.

We can use export and import settings to add multiple include directory to Eclipse. First, we click Export Settings button to open export dialog.

Fill Export to file input with your file output name. When we click Finish button, Eclipse will create a settings xml file. This is a example of content of this file :

<?xml version="1.0" encoding="UTF-8"?>
<cdtprojectproperties>
<section name="org.eclipse.cdt.internal.ui.wizards.settingswizards.IncludePaths">
<language name="C Source File">

</language>
<language name="Object File">

</language>
<language name="Assembly Source File">

</language>
</section>
<section name="org.eclipse.cdt.internal.ui.wizards.settingswizards.Macros">
<language name="C Source File">

</language>
<language name="Object File">

</language>
<language name="Assembly Source File">

</language>
</section>
</cdtprojectproperties>

If we want to add other include directory in C source, so we can add new include directory at bottom of text <language name=”C Source File”>. This is example if I want to add other include directory to Eclipse :

<?xml version="1.0" encoding="UTF-8"?>
<cdtprojectproperties>
<section name="org.eclipse.cdt.internal.ui.wizards.settingswizards.IncludePaths">
<language name="C Source File">
<includepath>/data/Project/opendtect/ODWork/include/Algo</includepath>
<includepath>/data/Project/opendtect/ODWork/include/AttributeEngine</includepath>
<includepath>/data/Project/opendtect/ODWork/include/Attributes</includepath>
<includepath>/data/Project/opendtect/ODWork/include/Basic</includepath>

Save xml file and use import file. This is a dialog window to import new Eclipse setting file :

If import file success, so when we open property window Eclipse at menu Path and Symbols, we can get new include folder directory at Eclipse. When we want to use this include directory, we can use import method at our new project.

5 Comments

Leave a Reply to totosugito Cancel reply

Your email address will not be published. Required fields are marked *