44

I have a C project that is built using a makefile, Eclipse constantly warns about "Invalid project path: Duplicate path entries", but I cannot figure out what the hell it wants me to do. I would like to disable this warning and continue with my life.

My application compiles and runs fine, with not a single warning except this one. Being a conscientious developer I am keen to fix this problem so I have the warm fuzzies only a clean build can bring.

David Martin
  • 1,045
  • 2
  • 11
  • 14
  • 1
    If you are using Eclipse 3.7/CDT 8 then check out the answer by Kenneth Evans. I haven't tested it yet but it looks good, if it works for you please leave a comment. – David Martin Jun 05 '12 at 19:16
  • Tested and seems to be working. It should be the accepted answer, IMHO. – ysap Aug 28 '12 at 20:08

9 Answers9

32

This worked for me with Eclipse 3.7.2 and CDT 8.0.2:

  1. Open the project properties | C/C++ Build | Discovery Options.
  2. Click the button by Clear discovered entries now:.
  3. Rebuild.

It is seems to be a new feature in CDT 8. I have had this "Invalid project path: Duplicate path entries" problem for years, and this is apparently the newly provided solution.

Before doing this there were duplicate paths under C/C++ General | Paths and Symbols | Includes tab. I could not get rid of these. They only appear when Show built-in values is checked, so they are apparently generated somehow. After doing the above they were replaced with a set that did not have duplicates. The only difference is that the same settings appeared under Assembly, GNU C, and GNU C++. Previously they were different sets. The ones for Assembly were empty, for example.

So far the problem has not returned.

Kenneth Evans
  • 2,179
  • 19
  • 26
  • Great answer. Another "hidden" solution to one of the numerous problems plaguing the Discovery/Indexer modules. The only problem is that I don't see a way to select multiple projects and perform the cleaning on all at once (on a 64-core workspace, I have 64 per-core projects plus some...). – ysap Aug 28 '12 at 20:13
  • Thank you, I've had this problem when using premake to generate gmakefiles and found the duplication hidden under the Paths and Symbols tab. – Jens Åkerblom Sep 23 '12 at 10:28
  • The discovery options seems to be present only in some cases (it definitely isn't present with autotools). In such case go to `.metadata/.plugins/org.eclipse.cdt.make.core/` and erase the bad paths. – Šimon Tóth May 27 '14 at 13:12
  • Thanks @Let_Me_Be that worked for me, even though, I found the faulty entries in my .cproject file. – dubbaluga Jul 15 '14 at 07:27
27

This problem is a real pain to deal with. It doesn't work very well.

This is applicable to Eclipse 3.4.1 / CDT 5.0.1

From what I can tell, when you create a "C/C++ Project" within CDT, it will try to auto-detect your include paths. Great idea, but the implementation is horrid.

If you delete or rename a directory, the old directory is leftover. If you rename the project, the old directory is leftover. When Eclipse can't find that old directory, it gives you that warning.

My solution is turning the automated discovery off entirely and managing my include paths manually. You need this list of include paths for things like ctrl-click (auto-navigate to defines/functions/files/etc) and shading out #define blocks. It builds the index off this list.

Here's what you need to do: Right click on your project in the project explorer and go to properties. Go to C/C++ Build -> Discovery Options Uncheck "Automate discovery of paths and symbols"

Now go to C/C++ General -> Paths and Symbols You'll see under the Includes tab Assembly, C and C++ languages with corresponding auto-discovered include directories. Go to all 3 languages and delete everything. Open your makefile and transcribe your includes into the corresponding language. A project rename will still cause the indexer to break. ${project_name} and other globals do not seem to work. If you're having trouble, use the "Workspace" button to browse to the directory you want to include, as that seems to always work but entering it manually does NOT. Hit apply, then OK. Right click your project, go to index->rebuild Restart eclipse.

This should fix things forever. Any time something improperly is shaded out due to a #define or #ifdef block, it's because that list of files is outdated. You'll also know that list is outdated if you get "unresolved inclusions" on #include lines.

Doug Schaefer, hopefully Google indexes this, you find your name, and you fix this awful implementation. =)

Jeff Lamb
  • 5,755
  • 4
  • 37
  • 54
  • 1
    Just as an update, you can use the ${ProjName} variable in place of the actual project name and it will persist through a project rename. – Jeff Lamb Aug 03 '09 at 18:07
  • Hi Jeff,after manually setting the paths how can we use the gdb. it keeps hanging at certain points. – Aditya P Jun 01 '11 at 11:14
13

I found this bug report to help my problem. I had moved some include paths and couldn't get rid of the old paths.

I've seen this problem too, old paths are never deleted. To manually fix the file you need to move/delete the ${projectname}.sc file found under ${workspace}/.metadata/.plugins/org.eclipse.cdt.make.core

https://bugs.eclipse.org/bugs/show_bug.cgi?id=206372

EJ.
  • 133
  • 1
  • 5
6

Using Eclipse Luna and CDT 8.5

I fixed the issue by

  1. Open the project properties | C/C++ General | Paths and Symbols
  2. Look at the Source Location tab, I had renamed a directory and it was not updated in this list.
  3. Rebuild
mark
  • 61
  • 1
  • 1
1

Here I just found another way to re-detect the path automatically:

  1. Open "Workspace Settings-> C/C++ -> Build -> Settings -> Discovery"
  2. Find "CDT Build-in Compiler Settings [Shard]"
  3. Click "Clear Entries" and "Reset" button on the right
  4. Rebuild projects and Done

Hope this will help.

Reference: http://qing.blog.sina.com.cn/1802712302/6b7334ee33004def.html

Ethan
  • 11
  • 1
0

No needs to remove .metadata guys, just delete all path located in C/C++ General -> Paths and Symbols -> Symbols and replace them on using click buttom but don't give the path manually

biegleux
  • 13,179
  • 11
  • 45
  • 52
bouum
  • 17
  • 1
0

You should check if you have manually defined a symbol that eclipse can figure out from your makefile. I have a project that has a manually written makefile and the problem was solved by removing symbols that I had manually added to C/C++ General -> Paths and Symbols -> Symbols.

0

Here's a late answer for Eclipse 4.4 (which does not have a Discovery option).

Delete the project's infoPath file. Eclipse or the ADT plugin (not sure which) will recreate it, and populate it with the correct paths.

You can find the project's infoPath file at <Eclipse workspace>/.metadata/.plugins/com.android.ide.eclipse.ndk/<project>.pathInfo.

I think Eclipse or the ADT plugin determines the new paths from two places: (1) the NDK directory set under Eclipse preferences, and (2) paths in Application.mk. All those paths become "Built-in" paths under Eclipse.

Also see How to change built-in C/C++ paths pointing to a deleted android-ndk-r9 installation?

Community
  • 1
  • 1
jww
  • 97,681
  • 90
  • 411
  • 885
0

It seems like a bug in CDT.

If you really want to get rid of it, you should try getting rid of the spaces in the project path; this was suggested in a search result for the error. If that doesn't work, you can try to open the .cproject file -it's where all the CDT settings lie- and check for an actual path with duplicate entries.

aib
  • 45,516
  • 10
  • 73
  • 79