如何在 Windows 上使用 GNU Make?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12881854/
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
How to use GNU Make on Windows?
提问by yak
I installed MinGW and MSYS, added C:\MinGW\bin
to PATH
but I still can't run Makefile on Windows' cmd
. I would like to run cmd.exe and there type, for example, make all
but my cmd says that there is no such command.
我安装了 MinGW 和 MSYS,添加C:\MinGW\bin
到PATH
但我仍然无法在 Windows 上运行 Makefile cmd
。我想运行 cmd.exe 并在那里输入,例如,make all
但我的 cmd 说没有这样的命令。
What should I do? I don't want to use MSYS shell, that's not the point. Any ideas how to use GNU Make in Windows cmd as I can do it in Ubuntu? I'm not interested in Cygwin
.
我该怎么办?我不想使用 MSYS shell,这不是重点。有什么想法可以像在 Ubuntu 中那样在 Windows cmd 中使用 GNU Make?我对 不感兴趣Cygwin
。
回答by user1594322
Here's how I got it to work:
这是我如何让它工作的:
copy c:\MinGW\bin\mingw32-make.exe c:\MinGW\bin\make.exe
Then I am able to open a command prompt and type make:
然后我可以打开命令提示符并键入 make:
C:\Users\Dell>make
make: *** No targets specified and no makefile found. Stop.
Which means it's working now!
这意味着它现在正在工作!
回答by Colin 't Hart
I'm using GNU Make from the GnuWin32 project, see http://gnuwin32.sourceforge.net/but there haven't been any updates for a while now, so I'm not sure on this project's status.
我正在使用来自 GnuWin32 项目的 GNU Make,请参阅http://gnuwin32.sourceforge.net/但现在有一段时间没有任何更新,所以我不确定这个项目的状态。
回答by Delfino
Although this question is old, it is still asked by many who use MSYS2.
虽然这个问题很老了,但仍然有很多使用MSYS2 的人问这个问题。
I started to use it this year to replace CygWin, and I'm getting pretty satisfied.
今年我开始用它来代替 CygWin,我已经很满意了。
To install make
, open the MSYS2 shell and type the following commands:
要安装make
,请打开 MSYS2 shell 并键入以下命令:
# Update the package database and core system packages
pacman -Syu
# Close shell and open again if needed
# Update again
pacman -Su
# Install make
pacman -S make
# Test it (show version)
make -v
回答by Buggieboy
You can add the application folder to your path from a command prompt using:
您可以使用以下命令从命令提示符将应用程序文件夹添加到您的路径:
setx PATH "%PATH%;c:\MinGW\bin"
setx PATH "%PATH%;c:\MinGW\bin"
Note that you will probably need to open a new command window for the modified path setting to go into effect.
请注意,您可能需要打开一个新的命令窗口,以使修改后的路径设置生效。
回答by Ivo Merchiers
As an alternative, if you just want to install make, you can use the chocolatey package managerto install gnu makeby using
作为替代方案,如果您只想安装 make,则可以使用Chocolatey 包管理器通过使用来安装gnu make
choco install make -y
choco install make -y
This deals with any path issues that you might have.
这处理您可能遇到的任何路径问题。
回答by VonC
While make itself is available as a standalone executable (gnuwin32.sourceforge.net
package make
), using it in a proper development environment means using msys2.
虽然 make 本身可作为独立的可执行文件(gnuwin32.sourceforge.net
packagemake
)使用,但在适当的开发环境中使用它意味着使用msys2。
Git 2.24 (Q4 2019) illustrates that:
Git 2.24(2019 年第四季度)说明:
See commit 4668931, commit b35304b, commit ab7d854, commit be5d88e, commit 5d65ad1, commit 030a628, commit 61d1d92, commit e4347c9, commit ed712ef, commit 5b8f9e2, commit 41616ef, commit c097b95(04 Oct 2019), and commit dbcd970(30 Sep 2019) by Johannes Schindelin (dscho
).
(Merged by Junio C Hamano -- gitster
--in commit 6d5291b, 15 Oct 2019)
见犯4668931,提交b35304b,提交ab7d854,提交be5d88e,提交5d65ad1,提交030a628,提交61d1d92,提交e4347c9,提交ed712ef,提交5b8f9e2,提交41616ef,提交c097b95(2019年10月4日),并提交dbcd970(2019年9月30日)作者:约翰内斯·辛德林 ( dscho
)。
(由Junio C gitster
Hamano合并-- --在提交 6d5291b 中,2019 年 10 月 15 日)
test-tool run-command
: learn to run (parts of) the testsuiteSigned-off-by: Johannes Schindelin
Git for Windows jumps through hoops to provide a development environment that allows to build Git and to run its test suite.
To that end, an entire MSYS2 system, including GNU make and GCC is offered as "the Git for Windows SDK".
It does come at a price: an initial download of said SDK weighs in with several hundreds of megabytes, and the unpacked SDK occupies ~2GB of disk space.A much more native development environment on Windows is Visual Studio. To help contributors use that environment, we already have a Makefile target
vcxproj
that generates a commit with project files (and other generated files), and Git for Windows'vs/master
branch is continuously re-generated using that target.The idea is to allow building Git in Visual Studio, and to run individual tests using a Portable Git.
test-tool run-command
:学习运行(部分)测试套件签字人:约翰内斯·辛德林
适用于 Windows 的 Git 跨越了障碍,提供了一个允许构建 Git 并运行其测试套件的开发环境。
为此,提供了整个 MSYS2 系统,包括 GNU make 和 GCC,作为“Git for Windows SDK”。
它确实是有代价的:上述 SDK 的初始下载需要数百兆字节,解压后的 SDK 占用约 2GB 的磁盘空间。Windows 上更原生的开发环境是 Visual Studio。为了帮助贡献者使用该环境,我们已经有一个 Makefile 目标
vcxproj
,它使用项目文件(和其他生成的文件)生成提交,并且vs/master
使用该目标不断重新生成Git for Windows 的分支。这个想法是允许在 Visual Studio 中构建 Git,并使用便携式 Git 运行单独的测试。
回答by DBourne
user1594322 gave a correct answer but when I tried it I ran into admin/permission problems. I was able to copy 'mingw32-make.exe' and paste it, over-ruling/by-passing admin issues and then editing the copy to 'make.exe'. On VirtualBox in a Win7 guest.
user1594322 给出了正确的答案,但是当我尝试它时,我遇到了管理/权限问题。我能够复制“mingw32-make.exe”并粘贴它,否决/绕过管理问题,然后将副本编辑为“make.exe”。在 Win7 来宾中的 VirtualBox 上。