Eclipse CDT Can't Find include file unless full relative path is used

16,648

Solution 1

The key to the answer was posted by dbrank0 but he didn't promote it to an answer so I just upvoted the comment. Something went wrong in the .cproject file and editing it manually fixed the problem.

Solution 2

Try to replace relative workspace path to real path (add same include as filesystem) in include directories project settings.

Share:
16,648
Tod
Author by

Tod

I got hooked on programming in 1980 at Argonne National Labs when they got an Apple ][ and were looking to make it do something. I wrote a data collection and plotting program that automated a lot of drudgery out of the environmental studies lab and I've never looked back. I've spent all but six years as a consultant learning new businesses and coding up solutions. I have a particular fondness for embedded systems. Now I find myself spending more and more time creating online video training courses for programmers. My latest Pluralsight course - Integrating Qt Quick With C++ went live on Pluralsight at the first quarter of 2015. This is the final course in the Qt Trilogy. An upcoming course: Introduction to Ada 2012 is slated to be published in July 2015. I also have two earlier courses from 2013 The Eclipse Guided Tour - Part 1 and Part 2 Sites Blogs mostly about C# and C++ My Consulting Company Home Page My Video Drum Lessons Twitter: @TodGentille

Updated on June 17, 2022

Comments

  • Tod
    Tod almost 2 years

    I've been using Eclipse for a while and this has me stymied. I created a library name ITS8410_LIB a few weeks ago and then let it sit while I worked on a supporting library called Reach_Lib. The directory include paths I added back when I first created the project work fine. Today I finished Reach_Lib and went to add its path to ITS8410_Lib. I used the project properties C++ settings to add a workspace path (like I've done many times before). I have only one build configuration. The path is shown in the image (the one highlighted in blue is the specific one I'm talking about in this question).

    enter image description here When I go to include the file in the source neither Eclipse (I see the yellow question mark) nor the compiler (I get a compiler error) can locate the file. If I add the a directory path using the full absolute path syntax the results are the same. I can modify the source code and specify the #include via a full relative path from the current directory, and it is found. Eclipse just won't use the path specified in the project settings. This same Reach_Lib has an associated unit test project and the path is specified with a workspace setting from there and it works fine.

    enter image description here

    Directory paths that were added before today appear fine. Paths (there are two libs showing this behavior) I add today just seem to be ignored. I took a look at the compiler settings (see image below) and the path specified to the compiler appears to be OK.

    enter image description here

    Running under Windows7 64 bit (but using a 32 bit version of Eclipse Indigo). I have tried:

    1. rebuilding indices
    2. Exiting and restarting Eclipse multiple times
    3. workspace and absolute file paths
    4. modifying the order of the include paths
    5. different .h include files in project

    Update

    I took a look into the .cproject file and while I don't know much about what these files are supposed to look like I think I have a problem. Maybe the question is: How do I tell Eclipse to rebuild the .cproject file? I appear to have two similar sections and Eclipse is getting confused. I can see different version numbers tagged as suffixes. It appears to me that the visual editors are letting me modify one section but the IDE and compiler only care about the other section. Here's the relevant portions

    ...
    

                    <folderInfo id="nbeclipse.toolchain.nbl.rel.396284009." name="/" resourcePath="">
                        <toolChain id="nbeclipse.toolchain.nbl.rel.tc.1465290409" name="NetBurner Device Library" superClass="nbeclipse.toolchain.nbl.rel.tc">
                            <targetPlatform id="nbeclipse.toolchain.nbl.rel.tc.targetPlatform.283367649" isAbstract="false" name="NetBurner Module Library" superClass="nbeclipse.toolchain.nbl.rel.tc.targetPlatform"/>
                            <builder buildPath="${workspace_loc:/ITS8410_Lib/Release}" id="nbeclipse.toolchain.nbl.rel.tc.builder.2064025940" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Release ELF builder (MINGW)" superClass="nbeclipse.toolchain.nbl.rel.tc.builder"/>
                            <tool id="nbeclipse.toolchain.nbl.rel.tc.gcc.278195048" name="GNU C Compiler" superClass="nbeclipse.toolchain.nbl.rel.tc.gcc">
                                <inputType id="nbeclipse.toolchain.nbl.rel.tc.gcc.input.1060035859" name="GNU C Input" superClass="nbeclipse.toolchain.nbl.rel.tc.gcc.input"/>
                            </tool>
                            <tool id="nbeclipse.toolchain.nbl.rel.tc.gpp.767008127" name="GNU C++ Compiler" superClass="nbeclipse.toolchain.nbl.rel.tc.gpp">
                                <option id="nbeclipse.toolchain.super.gcc.directories.includepaths.1666029541" name="Include paths (-I)" superClass="nbeclipse.toolchain.super.gcc.directories.includepaths" valueType="includePath">
                                    **inside here is an option list with all my include paths**
                        ...
                    </folderInfo>
    

    Then right after the folderInfo close tag another folderInfo section starts

                    <folderInfo id="nbeclipse.toolchain.nbl.rel.396284009.2022231003" name="/" resourcePath="src">
                        <toolChain id="nbeclipse.toolchain.nbl.rel.tc.1982112905" name="NetBurner Device Library" superClass="nbeclipse.toolchain.nbl.rel.tc" unusedChildren="">
                            <targetPlatform id="nbeclipse.toolchain.nbl.rel.tc.targetPlatform" isAbstract="false" name="NetBurner Module Library" superClass="nbeclipse.toolchain.nbl.rel.tc.targetPlatform"/>
                            <tool id="nbeclipse.toolchain.nbl.rel.tc.gcc.1671008421" name="GNU C Compiler" superClass="nbeclipse.toolchain.nbl.rel.tc.gcc.278195048">
                                <inputType id="nbeclipse.toolchain.nbl.rel.tc.gcc.input.436341699" name="GNU C Input" superClass="nbeclipse.toolchain.nbl.rel.tc.gcc.input"/>
                            </tool>
                            <tool id="nbeclipse.toolchain.nbl.rel.tc.gpp.498310867" name="GNU C++ Compiler" superClass="nbeclipse.toolchain.nbl.rel.tc.gpp.767008127">
    
                                **the newly added paths don't show up here, if I add them manually things start working**