Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
16 years ago

(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's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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