Eclipse-CDT:Windows 下 Linux 交叉编译时的自动路径发现

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3448592/
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-15 15:00:53  来源:igfitidea点击:

Eclipse-CDT: Automatic Path Discovery when cross-compiling for Linux under Windows

c++windowseclipsecross-platformeclipse-cdt

提问by IanH

I'm using Eclipse-CDT to develop and compile projects for Linux. As host both Linux or Windows may be used.

我正在使用 Eclipse-CDT 为 Linux 开发和编译项目。可以使用 Linux 或 Windows 作为主机。

The project is created as Makefile project with a special build command, so I changed the build-command from maketo 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 $PATHis set by the build command.)

该项目是使用特殊的构建命令创建为 Makefile 项目的,因此我将构建命令从make特殊更改为我们的特殊命令,并适当地更改了“构建”和“清理”命令行。build 命令使用不在 中的目录中的 gcc $PATH,因为整个编译器套件位于版本控制系统中。(正确$PATH由构建命令设置。)

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.

这在 Linux 下工作正常:Eclipse 会自动学习符号和包含文件。但是,在 Windows 下,可以识别符号,但不能识别包含路径。

When I have a look in the generated MyProject.sc file in the workspace/.metadata/.plugins/org.eclipse.cdt.make.coredirectory, I see that the Include-Files are recognized, but prepended with a C:\cygwin.

当我查看目录中生成的 MyProject.sc 文件时workspace/.metadata/.plugins/org.eclipse.cdt.make.core,我看到 Include-Files 已被识别,但前面带有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/incand Eclipse recognizes C:\cygwin\net_libs\lib1\inc.

GCC 命令行使用没有驱动器号的绝对路径。(整个源代码树位于一个特殊的驱动器上(例如W:),CWD 位于这个驱动器上)。例如gcc/g++被调用-I /net_libs/lib1/inc并且 Eclipse 识别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).

顺便说一句:标准包含路径被正确识别(例如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.

Build-Directory 设置为 Makefile 的目录,该目录与 Sources 和 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).

我尝试了各种“工具链”设置(Cygwin、MinGw、Linux gcc),结果每次都一样。(更改设置后,我什至停止了 Eclipse,删除了 sc 文件并再次启动了 Eclipse)。

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.

我不知道为什么 Eclipse 知道我在 C:\Cygwin 中的 Cygwin 安装 - 编译器或相关工具不使用该安装。

When I change the .sc file manually and correct the paths and restart Eclipse, everything works fine.

当我手动更改 .sc 文件并更正路径并重新启动 Eclipse 时,一切正常。

Do you have any hints what may be the problem?

你有什么提示可能是什么问题吗?

回答by Turbo J

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.

看看项目-> 属性-> C/C++ 构建-> 发现选项。
有一个编译器调用命令- 通常设置为gcc,这意味着“路径中的 gcc”。尝试从您的构建系统将其设置为您的 gcc。