简体   繁体   English

Eclipse CDT无效的项目路径

[英]Eclipse CDT Invalid Project Path

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. 我有一个使用makefile构建的C项目,Eclipse经常警告“无效的项目路径:重复的路径条目”,但我无法弄清楚它到底想要我做什么。 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. 作为一个尽职尽责的开发人员,我很想解决这个问题,所以我只有干净的构建才能带来温暖的模糊。

This worked for me with Eclipse 3.7.2 and CDT 8.0.2: Eclipse 3.7.2和CDT 8.0.2对我有用:

  1. Open the project properties | 打开项目属性| C/C++ Build | 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. 它似乎是CDT 8中的一个新功能。多年来我一直有这个“无效的项目路径:重复的路径条目”问题,这显然是新提供的解决方案。

Before doing this there were duplicate paths under C/C++ General | 在此之前,在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. 它们仅在选中Show内置值时出现,因此它们显然是以某种方式生成的。 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++. 唯一的区别是在Assembly,GNU C和GNU C ++下出现了相同的设置。 Previously they were different sets. 以前他们是不同的集合。 The ones for Assembly were empty, for example. 例如,装配的那些是空的。

So far the problem has not returned. 到目前为止,问题还没有回来。

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 这适用于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. 据我所知,当您在CDT中创建“C / C ++项目”时,它将尝试自动检测您的包含路径。 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. 当Eclipse找不到那个旧目录时,它会给你那个警告。

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. 您需要这个包含路径的列表,例如ctrl-click(自动导航到定义/ functions / files / etc)和阴影#define块。 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" 转到C / C ++ Build - > Discovery Options取消选中“自动发现路径和符号”

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. 现在转到C / C ++ General - >路径和符号您将在“包含”选项卡下看到汇编语言,C语言和C ++语言以及相应的自动发现包含目录。 Go to all 3 languages and delete everything. 转到所有3种语言并删除所有内容。 Open your makefile and transcribe your includes into the corresponding language. 打开您的makefile并将您的包含转录为相应的语言。 A project rename will still cause the indexer to break. 项目重命名仍将导致索引器中断。 ${project_name} and other globals do not seem to work. $ {project_name}和其他全局变量似乎不起作用。 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. 右键单击您的项目,转到index->​​ rebuild重新启动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. 任何由于#define或#ifdef块而导致阴影不正确的情况,都是因为该文件列表已过时。 You'll also know that list is outdated if you get "unresolved inclusions" on #include lines. 如果你在#include行上得到“未解决的内容”,你也会知道列表已经过时了。

Doug Schaefer, hopefully Google indexes this, you find your name, and you fix this awful implementation. Doug Schaefer,希望Google为此编制索引,你找到了你的名字,并解决了这个糟糕的实现问题。 =) =)

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 要手动修复文件,您需要移动/删除$ {workspace} /。metadata / .plugins / org.eclipse.cdt.make.core下的$ {projectname} .sc文件。

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

Using Eclipse Luna and CDT 8.5 使用Eclipse Luna和CDT 8.5

I fixed the issue by 我解决了这个问题

  1. Open the project properties | 打开项目属性| C/C++ General | C / C ++一般| 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 重建

Here I just found another way to re-detect the path automatically: 在这里,我发现了另一种自动重新检测路径的方法:

  1. Open "Workspace Settings-> C/C++ -> Build -> Settings -> Discovery" 打开“工作区设置 - > C / C ++ - >构建 - >设置 - >发现”
  2. Find "CDT Build-in Compiler Settings [Shard]" 找到“CDT内置编译器设置[碎片]”
  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 参考文献: http//qing.blog.sina.com.cn/1802712302/6b7334ee33004def.html

无需删除.metadata ,只需删除位于C / C ++中的所有路径 - > 路径和符号 - > 符号并使用点击按钮替换它们但不要手动提供路径

You should check if you have manually defined a symbol that eclipse can figure out from your makefile. 您应该检查是否已经手动定义了eclipse可以从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. 我有一个项目有一个手动编写的makefile,问题是通过删除我手动添加到C / C ++ General - > Paths and Symbols - > Symbols的符号来解决的。

Here's a late answer for Eclipse 4.4 (which does not have a Discovery option). 这是Eclipse 4.4的最新答案(没有Discovery选项)。

Delete the project's infoPath file. 删除项目的infoPath文件。 Eclipse or the ADT plugin (not sure which) will recreate it, and populate it with the correct paths. Eclipse或ADT插件(不确定哪个)将重新创建它,并使用正确的路径填充它。

You can find the project's infoPath file at <Eclipse workspace>/.metadata/.plugins/com.android.ide.eclipse.ndk/<project>.pathInfo . 您可以在<Eclipse workspace>/.metadata/.plugins/com.android.ide.eclipse.ndk/<project>.pathInfo找到项目的infoPath文件。

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 . 认为 Eclipse或ADT插件从两个地方确定新路径:(1)在Eclipse首选项下设置的NDK目录,以及(2) Application.mk路径。 All those paths become "Built-in" paths under Eclipse. 所有这些路径都成为Eclipse下的“内置”路径。

Also see How to change built-in C/C++ paths pointing to a deleted android-ndk-r9 installation? 另请参阅如何更改指向已删除的android-ndk-r9安装的内置C / C ++路径?

It seems like a bug in CDT. 这似乎是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. 如果这不起作用,您可以尝试打开.cproject文件 - 所有CDT设置所在的位置 - 并检查具有重复条目的实际路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM