Forum Discussion
(Eclipse) How to add directories to GCC include path
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.14 Replies
- Altera_Forum
Honored Contributor
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 - Altera_Forum
Honored Contributor
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. - Altera_Forum
Honored Contributor
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 - Altera_Forum
Honored Contributor
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. - Altera_Forum
Honored Contributor
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 - Altera_Forum
Honored Contributor
--- 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. - Altera_Forum
Honored Contributor
I'm pretty sure this is what you need:
http://www.altera.com/literature/hb/nios2/n2sw_nii5v2_01.pdf Jake - Altera_Forum
Honored Contributor
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. - Altera_Forum
Honored Contributor
It's on page 2-8.
Jake - Altera_Forum
Honored Contributor
--- 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!