Eclipse、cmake、Windows、MingW - 什么 Makefile 生成器?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7000780/
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, cmake, Windows, MingW - What Makefile generator?
提问by blubberbernd
What's the difference on Windows with cmake and eclipse and MingW if I choose "Eclipse MingW Makefile" or "Eclipse Unix Makefile"?
如果我选择“Eclipse MingW Makefile”或“Eclipse Unix Makefile”,在 Windows 上使用 cmake 和 eclipse 以及 MingW 有什么区别?
With the MingW one I always get an error with "sh.exe" (that vanishes if I re-hit "Configure"), with the Unix one I always have to specifiy windres manually because cmake can't find it.
使用 MingW 时,我总是收到“sh.exe”错误(如果我重新点击“配置”,该错误就会消失),而使用 Unix 时,我总是必须手动指定 windres,因为 cmake 找不到它。
Does this make any difference for Eclipse or something else?
这对 Eclipse 或其他东西有什么影响吗?
Both generated Makefiles work with Eclipse and MingW and compile my project.
生成的 Makefile 都可以与 Eclipse 和 MingW 一起使用并编译我的项目。
What Makefile should I choose? And why?
我应该选择什么 Makefile?为什么?
回答by JesperE
This is really a mess.
这真是一团糟。
CMake has a number of different Makefile generators on Windows: MSYS, MinGW, NMake, and Unix. The CDT generator works on top of the Makefile generators by alsogenerating an Eclipse project for you. Currently, only MinGW, NMake, and Unix are supported by the CDT generator.
CMake 在 Windows 上有许多不同的 Makefile 生成器:MSYS、MinGW、NMake 和 Unix。CDT 生成器在 Makefile 生成器之上工作,还为您生成一个 Eclipse 项目。目前,CDT 生成器仅支持 MinGW、NMake 和 Unix。
The difference between these are which "make" flavor it uses. MinGW, MSYS, and Unix are all variants of GNU make (in this context, Unix means "Cygwin"). The difference between these are mostly related to how commands are executed, more specifically which shell is used to execute the commands. GNU make will try very hard to use "sh.exe" instead of "cmd.exe", and this is usually where things go wrong: having a command in a Makefile which assumes details about which shell being used for execution. Another problem when choosing GNU make flavor is to figure out which standard Unix utilities are available (sed/grep/etc). One notable detail is that if GNU make is using cmd.exe to execute commands, it will not support parallell builds.
它们之间的区别在于它使用的是哪种“制造”风味。MinGW、MSYS 和 Unix 都是 GNU make 的变体(在这种情况下,Unix 的意思是“Cygwin”)。它们之间的区别主要与命令的执行方式有关,更具体地说,是使用哪个 shell 来执行命令。GNU make 会非常努力地使用“sh.exe”而不是“cmd.exe”,这通常是出错的地方:在 Makefile 中有一个命令,它假定有关用于执行哪个 shell 的详细信息。选择 GNU make 风格时的另一个问题是确定哪些标准 Unix 实用程序可用(sed/grep/etc)。一个值得注意的细节是,如果 GNU make 使用 cmd.exe 来执行命令,它将不支持并行构建。
If you use Unix Makefiles, CMake will assume that your make is a Cygwin one, with full Unix emulation.
如果您使用 Unix Makefiles,CMake 将假定您的 make 是 Cygwin 的,具有完整的 Unix 模拟。
Also make sure that you actually run the "right" make. If you have generated Unix Makefiles, but you have MinGW make first in your PATH, then typing "make" in your build tree is likely to fail with weird errors.
还要确保您实际运行了“正确”的 make。如果你已经生成了 Unix Makefile,但是你的 PATH 首先有 MinGW make,那么在你的构建树中输入“make”很可能会失败并出现奇怪的错误。
But about your question: it really doesn't matter as long as it works.
但是关于你的问题:只要它有效,它真的无关紧要。
回答by ZJR
cmake -G"MSYS Makefiles"
helps a lot when compiling for MinGW
cmake -G"MSYS Makefiles"
为 MinGW 编译时有很大帮助