Eclipse CDT 无效的项目路径

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/307367/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 18:31:16  来源:igfitidea点击:

Eclipse CDT Invalid Project Path

eclipseeclipse-cdt

提问by David Martin

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.

我有一个使用 makefile 构建的 C 项目,Eclipse 不断警告“无效的项目路径:重复的路径条目”,但我无法弄清楚它到底想让我做什么。我想禁用此警告并继续我的生活。

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.

我的应用程序编译并运行良好,除了这个警告之外没有任何警告。作为一名尽职尽责的开发人员,我热衷于解决这个问题,所以我只有干净的构建才能带来温暖的模糊。

采纳答案by Kenneth Evans

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 | Discovery Options.
  2. Click the button by Clear discovered entries now:.
  3. Rebuild.
  1. 打开项目属性 | C/C++ 构建 | 发现选项。
  2. 单击立即清除发现的条目按钮:。
  3. 重建。

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 | 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.

在这样做之前,C/C++ General 下有重复的路径 | 路径和符号 | 包括选项卡。我无法摆脱这些。它们仅在选中显示内置值时才会出现,因此它们显然是以某种方式生成的。完成上述操作后,它们被替换为没有重复的集合。唯一的区别是相同的设置出现在汇编、GNU C 和 GNU C++ 下。以前它们是不同的集合。例如,Assembly 的那些是空的。

So far the problem has not returned.

到目前为止,问题还没有恢复。

回答by Jeff Lamb

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. Great idea, but the implementation is horrid.

据我所知,当您在 CDT 中创建“C/C++ 项目”时,它会尝试自动检测您的包含路径。好主意,但实施起来很糟糕。

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. It builds the index off this list.

我的解决方案是完全关闭自动发现并手动管理我的包含路径。你需要这个包含路径的列表,比如 ctrl-click(自动导航到定义/函数/文件/等)和阴影 #define 块。它从这个列表中建立索引。

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. 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.

现在转到 C/C++ General -> Paths and Symbols 您将在 Includes 选项卡下看到程序集、C 和 C++ 语言以及相应的自动发现的包含目录。转到所有 3 种语言并删除所有内容。打开您的 makefile 并将您的包含内容转录成相应的语言。项目重命名仍会导致索引器损坏。${project_name} 和其他全局变量似乎不起作用。如果您遇到问题,请使用“工作区”按钮浏览到您要包含的目录,因为这似乎总是有效,但手动输入则无效。点击应用,然后确定。右键单击您的项目,转到 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. You'll also know that list is outdated if you get "unresolved inclusions" on #include lines.

这应该永远解决问题。任何时候由于#define 或#ifdef 块而使某些内容不正确地被遮蔽,这是因为该文件列表已过时。如果您在 #include 行上看到“未解析的包含”,您也会知道该列表已过时。

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

Doug Schaefer,希望谷歌索引这个,你找到你的名字,然后修复这个糟糕的实现。=)

回答by EJ.

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

回答by mark

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 | 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
  1. 打开项目属性 | C/C++ 通用 | 路径和符号
  2. 查看“源位置”选项卡,我重命名了一个目录,但它没有在此列表中更新。
  3. 重建

回答by Ethan

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
  1. 打开“工作区设置->C/C++->构建->设置->发现”
  2. 找到“CDT内置编译器设置[Shard]”
  3. 单击右侧的“清除条目”和“重置”按钮
  4. 重建项目并完成

Hope this will help.

希望这会有所帮助。

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

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

回答by jww

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

这是 Eclipse 4.4(没有 Discovery 选项)的最新答案。

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

删除项目的infoPath文件。Eclipse 或 ADT 插件(不确定是哪个)将重新创建它,并用正确的路径填充它。

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

您可以infoPath<Eclipse workspace>/.metadata/.plugins/com.android.ide.eclipse.ndk/<project>.pathInfo.

I thinkEclipse 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.

认为Eclipse 或 ADT 插件从两个地方确定新路径:(1) Eclipse 首选项下设置的 NDK 目录,以及 (2) Application.mk. 所有这些路径都成为 Eclipse 下的“内置”路径。

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

另请参阅如何更改指向已删除的 android-ndk-r9 安装的内置 C/C++ 路径?

回答by bouum

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

不需要删除.metadata家伙,只需删除位于C/C++ General-> Paths and Symbols-> Symbols 中的所有路径, 并使用单击按钮替换它们,但不要手动提供路径

回答by bouum

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.

您应该检查您是否手动定义了一个 eclipse 可以从您的 makefile 中找出的符号。我有一个项目,它有一个手动编写的 makefile,问题是通过删除我手动添加到 C/C++ General -> Paths and Symbols -> Symbols 的符号解决的。

回答by aib

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 设置所在的位置 - 并检查具有重复条目的实际路径。