Adding sources to Eclipse CDT project gives error: folder "overlaps the location of the project that contains the linked resource"

Adding sources to Eclipse CDT project gives error: folder "overlaps the location of the project that contains the linked resource"

我在向 Eclipse CDT 项目的源文件位置列表中添加另一个 "linked folder" 时遇到问题。

我的项目位于 /m/a/prj/eclipse 我的消息来源在
/m/a/src
/m/b/src
/m/c/src
等等

但是,当我尝试添加时
/m
到源文件夹列表,我收到错误:

"Cannot create a link to '....../m' because 
it overlaps the location of the project that contains the linked resource."

我尝试手动编辑 .project 文件,但在重新加载项目后出现了同样的错误。

有解决办法吗?

您不能 link 将作为项目目录的祖先的目录添加到项目中,因为这会在项目的目录结构中创建循环。

相反,您可以单独 link 祖先目录的子目录(如 /m/a/src/m/b/src 等)。

如果您需要直接包含在祖先目录中的文件,例如 /m/file,您可以 link 一个单独的文件:

  • 转到File -> New -> Other...
  • 选择General -> File
  • Advanced 下,选择 "Link to file in the file system"