7
votes

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** 
3
What I would try is to remove project (keep source), delete project definition (.cproject, .settings...), create new project and add existing source. Other thought: Check if you're configuring same configuration (release/debug) as the one, you are trying to build. - dbrank0
I don't have a debug config only the single release configuration. The reason I wanted to avoid creating a new project and re-importing the source code is due to source code control. I use Mercurial and I'm pretty sure I'll lose all revision history on the files. Even if I copy over the .hg folder it looks like it will consider all the old files deleted and all the imported files as new files with no history. Not the end of the world but I was hoping to maintain the file history. - Tod
@dbrank0 - I think the mercurial problem is stupidity on my part. I left the "create top folder" button checked when I did the import and didn't realize it. That caused the mismatch. If you promote your comment to an answer I'll mark it as such. - Tod

3 Answers

2
votes

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.

1
votes

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

0
votes

full absolute path is okay at any time. when use the relative directory you should be careful. in eclipse the current directory is not the same as run directory.

string strRunDir, strCurDir;
strRunDir = AfxGetApp()->m_pszExeName;
strCurDir = GetCurrentDirectory(...);

and strRunDir != strCurDir;

when you want to use the relative directory, you should reference to the runDir;