Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12612 Discussions

(Eclipse) How to add directories to GCC include path

Altera_Forum
Honored Contributor II
4,895 Views

Hi, 

 

I'm trying to bring some existing code into a program that relies on the GCC compiler finding include files in other project include directories 

 

For example x/x.c says: 

# include "myinclude.h" 

 

To include the file include_dir/myinclude.h 

 

When I bring the code into eclipse it initially reports "unresolved inclusion: myinclude.h" at the line where the file is included - which is completely reasonable as I haven't told eclipse where to find myinclude.h. 

 

Then I went into the project properties to c/c++ general --> paths and symbols ->includes and added include_dir (export, for all languages, workspace directory). 

 

This resolves the 'unresolved inclusion' message but when I try to build the code the include file isn't found by the compiler. Looking at the compiler command line there is no '-I' option on the compiler command line to tell the compiler about the directories I added. 

 

Any suggestions on how to get the GCC to look in additional directories for its include files? 

 

Thanks, 

Darren.
0 Kudos
14 Replies
Altera_Forum
Honored Contributor II
2,641 Views

What version of the tools are you using? If you are using the Nios II IDE, you can simply add the -I option to the compiler flags. Open the software project's properties then click "C/C++ Build" on the left. Then under "Nios II Compiler" click the "General" section. The top entry is for compiler flags. Here you can put in any gcc compiler flags (like -I) 

 

Jake
0 Kudos
Altera_Forum
Honored Contributor II
2,641 Views

Hi Jake, 

 

I've just moved from the NIOS 9.0 IDE to NIOS 9.1 Software Built Tools for Eclipse (a decision I'm quickly regretting ). 

 

It seems there's an entry in the generated Makefile (ALT_INCLUDE_DIRS) that looks right but I'm not sure if Eclipse will ever overwrite it. 

 

Thanks, 

Darren.
0 Kudos
Altera_Forum
Honored Contributor II
2,641 Views

Let me first say that I believe moving to the software build tools flow is a good choice. You just need to work through the transition. Once you do I think you'll be glad you did. Essentially Eclipse has very limited interaction. You must do everything under the NIOS II section of the project's properties. These settings in turn make modifications to the project's makefile. With the build tools it's a makefile you are maintaining and configuring rather than eclipse project settings. 

 

Jake
0 Kudos
Altera_Forum
Honored Contributor II
2,641 Views

Thanks Jake. Unfortunately there doesn't seem to be anything in the NiosII entry for the project to help me with this issue but it does seem like changing this data in Makefile directly is safe amd gets the job done 

 

It's just a shame that setting the directory path in eclipse doesn't push the changes into the Makefile but I guess I'll have to live with that :) 

 

Thanks again, 

Darren.
0 Kudos
Altera_Forum
Honored Contributor II
2,641 Views

In the 9.1 tools, you open the project properties then expand the "Nios II Application Properties" and click on the "Nios II Application Paths" subsection. Then you add your include folders to the "Application include directories" area. These will become "-I" statements in the makefile. 

 

Jake
0 Kudos
Altera_Forum
Honored Contributor II
2,641 Views

 

--- Quote Start ---  

In the 9.1 tools, you open the project properties then expand the "Nios II Application Properties" and click on the "Nios II Application Paths" subsection. Then you add your include folders to the "Application include directories" area. These will become "-I" statements in the makefile. 

 

Jake 

--- Quote End ---  

 

 

I see what you were getting at now - sorry for being slow. I guess I need to look at the NIOS Application properties first and only then resort to the more-general Eclipse ones. 

 

Do you know if there's documentation for the Altera-specific Eclipse features available? I grabbed the one-click documentation for Nios 9.1 but there didn't seem to be anything applicable. 

 

Thanks, 

Darren.
0 Kudos
Altera_Forum
Honored Contributor II
2,641 Views

I'm pretty sure this is what you need: 

http://www.altera.com/literature/hb/nios2/n2sw_nii5v2_01.pdf 

 

Jake
0 Kudos
Altera_Forum
Honored Contributor II
2,641 Views

Thanks. I skimmed the full version and didn't notice anything appropriate - the text seem mostly tutorial rather than references.  

 

I didn't see any references to the properties screen you directed me to but I'll keep looking. 

 

Darren.
0 Kudos
Altera_Forum
Honored Contributor II
2,641 Views

It's on page 2-8. 

 

Jake
0 Kudos
Altera_Forum
Honored Contributor II
2,641 Views

 

--- Quote Start ---  

"Nios II Application Paths" subsection. 

--- Quote End ---  

 

Yep - that worked for me; I had the same problem, and was a bit confused because the indexer worked but the compiler didn't!
0 Kudos
Altera_Forum
Honored Contributor II
2,641 Views

This is exactly the same problem I am having. I added my include paths under C/C++ General -> Paths and Symbols. This did not let the compiler find my include paths other than the default ones and I could see the gcc lines did not mention my paths. Project Explorer DID display the paths under Includes. I then added the paths under Nios II Application Properties. I selected Convert Relative Path and hit Apply and Close. Nothing changed in the project explorer, i.e. the new paths weren't listed. I opened the project properties again and went to the Nios II Application Properties section, and the relative paths were gone, as if I had never added them. I added them as absolute paths and they appeared in the project explorer AND under the C/C++ General -> Paths and Symbols section. It seems that C/C++ General -> Paths and Symbols is only for displaying the defaults and what is added, not for actually adding anything despite the fact the interface makes you think you can.  

 

There is something wrong here. The C/C++ General -> Paths and Symbols section and the Nios II Application Properties seem to do the same thing, even though only the latter really works. Also, the relative paths do not appear to work or even be saved.
0 Kudos
Altera_Forum
Honored Contributor II
2,641 Views

Strange. I've been using Nios II project properties to set the application include paths w/ the relative paths option and it seems to work perfectly.  

 

It also survives bring checked in via CVS and being checked out somewhere else which has proved to be handy. 

 

I wish that relative paths could be added directly (rather than selecting the whole path) but it's a very minor thing.
0 Kudos
Altera_Forum
Honored Contributor II
2,641 Views

basafran, I had the same problem as you - after entering the include path in Properties -> Nios II Application Properties -> Nios II Application Paths they where gone when the settings opened again. 

I think there is a problem with the access rights of file system. After I chaged they with 

chmod -R +w <application_dir> in the Nios command shell the settings maintains. (the rights for the bsp dir I have also changed) 

 

Jens
0 Kudos
Altera_Forum
Honored Contributor II
2,641 Views

Alternatively I changed the Makefile in the application directory. There is an APP_INCLUDE_DIRS variable which I have set: 

 

# List of application specific include directories, library directories and library names 

APP_INCLUDE_DIRS += <path1> 

APP_INCLUDE_DIRS += <path2> 

 

The Eclipse IDE recognizes the changes and shows the paths in Properties -> Nios II Application Properties -> Nios II Application Paths 

 

Jens
0 Kudos
Reply