带有 Cygwin GCC 的 Eclipse CDT:自动发现符号和路径
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1450654/
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
Eclipse CDT with Cygwin GCC: automatic discovery of symbols and paths
提问by Amro
I am using Eclipse CDT with Cygwin GCC 3 as compiler. My project is using a custom Makefile.
我使用 Eclipse CDT 和 Cygwin GCC 3 作为编译器。我的项目正在使用自定义 Makefile。
The problem is that when debugging the code, it couldn't locate the source files, even though I added a custom path mapping for: /cygdrive/c <-> c:\
问题是在调试代码时,它找不到源文件,即使我添加了自定义路径映射: /cygdrive/c <-> c:\
That in addition to the fact that I am getting "unresolved inclusion" for all standard header files, even though the program compiles and run fine.
除了我收到所有标准头文件的“未解决的包含”这一事实之外,即使程序编译并运行良好。
I traced the problem to the "automatic discovery" option, which shows the following error:
我将问题追溯到“自动发现”选项,该选项显示以下错误:
Note that I made sure that the workspace directory is on a path without any spaces. The weird thing is that when I run that problematic command in the shell, it runs just fine with the following output:
请注意,我确保工作区目录位于没有任何空格的路径上。奇怪的是,当我在 shell 中运行那个有问题的命令时,它运行得很好,输出如下:
$ gcc -E -P -v -dD C:/Users/Amro/workspace/.metadata/.plugins/org.eclipse.cdt.make.core/specs.c
Reading specs from /usr/lib/gcc/i686-pc-cygwin/3.4.4/specs
Configured with: /managed/gcc-build/final-v3-bootstrap/gcc-3.4.4-999/configure --verbose --program-suffix=-3 --prefix=/usr --exec-prefix=/usr --sysconfdir=/etc --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --enable-languages=c,ada,c++,d,f77,pascal,java,objc --enable-nls --without-included-gettext --enable-version-specific-runtime-libs --without-x --enable-libgcj --disable-java-awt --with-system-zlib --enable-interpreter --disable-libgcj-debug --enable-threads=posix --enable-java-gc=boehm --disable-win32-registry --enable-sjlj-exceptions --enable-hash-synchronization --enable-libstdcxx-debug
Thread model: posix
gcc version 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)
/usr/lib/gcc/i686-pc-cygwin/3.4.4/cc1.exe -E -quiet -v -P -D__CYGWIN32__ -D__CYGWIN__ -Dunix -D__unix__ -D__unix -idirafter /usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../include/w32api -idirafter /usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/lib/../../include/w32api C:/Users/Amro/workspace/.metadata/.plugins/org.eclipse.cdt.make.core/specs.c -mtune=pentiumpro -dD
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/include"
ignoring duplicate directory "/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/lib/../../include/w32api"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include
/usr/include
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../include/w32api
End of search list.
#define __STDC_HOSTED__ 1
#define __GNUC__ 3
[.... truncated ....]
#define __unix__ 1
#define __unix 1
I also tried to manually add to the include path:
我还尝试手动添加到包含路径:
How can I fix this so that it discovers both the include paths and the defined symbols? Should I try turn off the auto discovery and hardcode the required paths in the .cprojectfile? Any help is appreciated (I only ask that you don't suggest using MinGW instead of Cygwin!)
我该如何解决这个问题,以便它发现包含路径和定义的符号?我应该尝试关闭自动发现并在.cproject文件中硬编码所需的路径吗?感谢任何帮助(我只要求您不要建议使用 MinGW 而不是 Cygwin!)
回答by DaveParillo
Yours is a frequest source of complaints regarding mixing eclipse & cygwin. The crux of the problem is that eclipse understands only the windows environment & cygwin, well not so much.
您是有关混合 eclipse 和 cygwin 的投诉来源。问题的关键是eclipse只了解windows环境和cygwin,不太了解。
Define your paths in in eclipse windows style. Also is /usr is under C:\cygwin, you have to give it the full path. Otherwise eclipse is going to try to find it under c:\usr and come up empty.
在 Eclipse 窗口样式中定义您的路径。/usr 也位于 C:\cygwin 下,您必须为其提供完整路径。否则 eclipse 将尝试在 c:\usr 下找到它,然后发现它是空的。
Also, are your path definitions appending to or replacing your windows environment? You'll probably be happier appending to your environment rather than replacing.
另外,您的路径定义是否附加到或替换了您的 Windows 环境?您可能会更高兴添加到您的环境中而不是替换。
Never tried autodetect - you may have to hard code those paths in .cproject
从未尝试过自动检测 - 您可能必须在 .cproject 中对这些路径进行硬编码