在 Ubuntu Linux 中从 Eclipse 交叉编译 Windows 应用程序?

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

Cross-compiling Windows applications from Eclipse in Ubuntu Linux?

windowslinuxeclipsemingwcross-compiling

提问by Frxstrem

I am trying to set up a programming environment to compile Windows executables and libraries from Ubuntu Linux. I have installed MinGW (from the official Ubuntu repositories) and it is working great from the command line; however, I try to use it from within Eclipse, and it neither detects it automatically nor can I seem to find a way to make it work manually.

我正在尝试设置一个编程环境来从 Ubuntu Linux 编译 Windows 可执行文件和库。我已经安装了 MinGW(来自官方 Ubuntu 存储库)并且它在命令行中运行良好;但是,我尝试在 Eclipse 中使用它,它既不会自动检测到它,也无法找到一种方法让它手动工作。

So, my question is, how can I set up Eclipse to cross-compile Windows applications, preferably using MinGW (although other, alternative solutions are welcome too)?

所以,我的问题是,如何设置 Eclipse 来交叉编译 Windows 应用程序,最好使用 MinGW(尽管也欢迎其他替代解决方案)?

采纳答案by Max

I used Eclipse Indigo (3.7) with CDT package on MacOSX to cross-compile Windows apps and it works fine. Just for a reference to others interested, I installed mingw with port install i386-mingw32-gcc -universal. In CDT, create new C or C++ project, on the next page of the wizard, select Project Type as "Cross-Compile Project", toolchain - "Cross GCC". On the next page, type Tool Command Prefix (I have i386-mingw32-) and provide a path to mingw tools.

我在 MacOSX 上使用 Eclipse Indigo (3.7) 和 CDT 包来交叉编译 Windows 应用程序,它工作正常。仅供有兴趣的其他人参考,我安装了 mingw 与port install i386-mingw32-gcc -universal. 在 CDT 中,创建新的 C 或 C++ 项目,在向导的下一页上,选择项目类型为“Cross-Compile Project”,工具链 - “Cross GCC”。在下一页上,键入 Tool Command Prefix(我有i386-mingw32-)并提供 mingw 工具的路径。

Complete the wizard, add your files and build!

完成向导,添加文件并构建!

Cheers, Max

干杯,马克斯

回答by psihodelia

Eclipse requires appropriate executables in your PATH variable. Find where is your MinGW GCC compiler called gcc and then just add its path into your Windows PATH variable. If you want POSIXapplications development using Eclipse, please consider Cygwininstead of MinGW.

Eclipse 需要您的 PATH 变量中有适当的可执行文件。找到名为 gcc 的 MinGW GCC 编译器的位置,然后将其路径添加到 Windows PATH 变量中。如果您想使用 Eclipse 开发POSIX应用程序,请考虑使用Cygwin而不是 MinGW。