Eclipse-CDT:在 Windows 下对 Linux 进行交叉编译时自动路径发现
我正在使用 Eclipse-CDT 来开发和编译 Linux 项目。 Linux 或 Windows 均可用作主机。
该项目是使用特殊的构建命令创建为 Makefile 项目的,因此我将构建命令从 make
更改为我们的特殊命令,并相应地更改了“Build”和“Clean”命令行。构建命令使用不在 $PATH
中的目录中的 gcc,因为整个编译器套件位于版本控制系统中。 (正确的 $PATH
由构建命令设置。)
这在 Linux 下工作得很好:Eclipse 自动学习符号和包含文件。 但是,在 Windows 下,可以识别符号,但不能识别包含路径。
当我查看 workspace/.metadata/.plugins/org.eclipse.cdt.make.core
目录中生成的 MyProject.sc 文件时,我发现包含文件已被识别,但前面带有 C:\cygwin
。
GCC 命令行使用不带驱动器号的绝对路径。 (整个源代码树位于一个特殊的驱动器上(例如W:
),CWD就在这个驱动器上)。 例如,使用 -I /net_libs/lib1/inc
调用 gcc
/g++
并且 Eclipse 识别 C:\cygwin\net_libs\lib1 \inc
。
顺便说一句:标准包含路径被正确识别(例如W:/toolchain/win32/i686-pc-linux-gnu/include/c++/4.2.1
)。
Build-Directory 设置为 Makefile 的目录,该目录与源文件和包含文件位于同一驱动器上。
我尝试了各种“工具链”设置(Cygwin、MinGw、Linux gcc),每次结果都是相同的。 (更改设置后,我什至停止了 Eclipse,删除了 sc 文件并再次启动了 Eclipse)。
我不知道为什么 Eclipse 知道我在 C:\Cygwin 中的 Cygwin 安装 - 编译器或相关工具不使用该安装。
当我手动更改 .sc 文件并更正路径并重新启动 Eclipse 时,一切正常。
您有任何提示可能是什么问题吗?
I'm using Eclipse-CDT to develop and compile projects for Linux. As host both Linux or Windows may be used.
The project is created as Makefile project with a special build command, so I changed the build-command from make
to our special one and the "Build" and "Clean" commandline approbriately. The build command uses a gcc from a directory not in $PATH
, because the whole compiler-suite is located in the version control system. (Correct $PATH
is set by the build command.)
This works fine under Linux: Eclipse learns the Symbols and Include Files automatically.
However, under Windows the Symbols are recognized, but the Include Paths aren't.
When I have a look in the generated MyProject.sc file in the workspace/.metadata/.plugins/org.eclipse.cdt.make.core
directory, I see that the Include-Files are recognized, but prepended with a C:\cygwin
.
The GCC command line uses absolute paths without the Drive letter.
(The whole source tree is located on a special Drive (e.g. W:
), CWD is on this drive ).
E.g. gcc
/g++
is invoked with -I /net_libs/lib1/inc
and Eclipse recognizes C:\cygwin\net_libs\lib1\inc
.
BTW: The standard-include paths are recognized correctly (e.g. W:/toolchain/win32/i686-pc-linux-gnu/include/c++/4.2.1
).
The Build-Directory is set to the directory of the Makefile which is on the same Drive as the Sources and Includes.
I tried various "Toolchain" settings (Cygwin, MinGw, Linux gcc), the result is same every time. (After changing the settings, I even stopped Eclipse, deleted the sc file and started Eclipse again).
I don't know why Eclipse knows about my Cygwin installation in C:\Cygwin - the installation is NOT used by the compiler or related tools.
When I change the .sc file manually and correct the paths and restart Eclipse, everything works fine.
Do you have any hints what may be the problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看项目->属性->C/C++ 构建->发现选项。
有一个编译器调用命令 - 通常设置为
gcc
,这意味着“gcc in PATH”。尝试从构建系统将其设置为 gcc。Have a look at Project->Propterties->C/C++ Build->Discovery Options.
There is a Compiler invocation command - usually set to
gcc
, which means "gcc in PATH". Try setting this to your gcc from your build system.