23

抱歉,如果这是一个相当愚蠢的问题,但我正在努力在 NetBeans 中设置 C++(这需要 MinGW)。它在 NetBeans 的 C/C++ 部分的文档中说,它只适用于 MSYS 的 make,而不是 MinGW 的 make。我想知道两者之间的区别,所以我用谷歌搜索并提出了这个问题,它说 MinGW 包含两种不同的品牌,mingw32-make(MinGW 的品牌)和make(MSYS 的品牌)。然后我在 MinGW 网站的 wiki 上挖了一点,发现这篇文章隐藏在常见问题解答中:

make 的“本机”(即:依赖于 MSVCRT)端口缺少某些功能,并且由于 Win32 上缺少 POSIX 而修改了功能。MSYS 发行版中还存在一个依赖于 MSYS 运行时的 make 版本。该端口的操作更多地与 make 的预期操作相同,并且在执行期间减少了令人头疼的问题。基于此,MinGW 开发人员/维护人员/打包人员决定最好重命名本机版本,以便“本机”版本和 MSYS 版本可以同时存在而不会发生文件名冲突。

那么,如果有两个 make 副本,哪一个在 MSYS shell 中可用,哪一个在cmd.exe? 两者的主要区别是什么?

4

1 回答 1

22

The main practical difference between the two makes, the MSYS version and the native version, is that former uses the MSYS shell to execute its commands, while the later uses cmd. This means with the MSYS version of make you can write recipes much the same as you would on Unix or Linux system, while with the native Windows version you might have to do things differently. For simple command execution they work the same, but for more complicated actions the recipes will have to differ because cmd has a much different syntax than Unix shells.

For example you might handle recursive builds like this with MSYS make:

recurse-subdirs:
    for i in $(SUBDIRS);            \
    do                              \
        cd $$i && make all || exit; \
    done

While with the native version of make you'd have to do something like this instead:

recurse-subdirs: FORCE
    for %%i in ($(SUBDIRS)) do     \
        cd %%i && make all || exit

With the MSYS make its also safe to assume the usual Unix commands are available (eg. rm *.o), while with the native make you'll want to use Windows commands instead (eg. del *.o).

Which version of make is available is dependent on how you set the PATH. If both versions of make, one named make, and one named mingw32-make, can be found by searching PATH then both commands will be available. This true whether you're using the MSYS shell or cmd.

于 2014-08-25T06:41:54.597 回答