我正在遵循某人的指示,我将其存储库克隆到我的机器上。我想使用make命令作为设置代码环境的一部分,但我使用的是Windows。我在网上搜索了一下,但只找到了一个make.exe文件、一个make. 4.1.tar.gz文件(我不知道接下来该怎么处理它)和如何下载MinGW(适用于GNU;但安装后,我没有发现任何提到“make”)。

在没有GNU编译器或相关包的情况下,如何使用Windows中的make ?


当前回答

在windows 10或windows 11操作系统上执行winget install GnuWin32命令。在命令行或powershell中进行Make以快速安装。然后可以使用cmake命令。

没有必要再安装巧克力了。

其他回答

从他们的官方网站GnuWin32下载make.exe

在下载会话中,单击 完整的包,除了源代码。 按照安装说明安装。 完成后,将<安装目录>/bin/添加到PATH变量中。

现在您将能够在cmd中使用make。

你也可以安装scoop,然后运行:

scoop install make

安装Msys2 http://www.msys2.org 遵循安装说明 使用$ pacman -S make gettext base-devel安装make 添加C:\msys64\usr\bin\到您的路径

除了GNU之外,您可能还需要许多coreutils。Touch, rm, cp, sed, test, tee, echo等等。构建系统可能需要bash特性,如果没有其他原因,通常从进程ID($$$$)创建临时文件名。没有bash是不行的。你可以用Windows上流行的POSIX模拟器得到所有东西:

Cygwin (http://www.cygwin.org/) Probably the most popular one and the most compatible with POSIX. Has some difficulties with Windows paths and it's slow. GNUWin (http://gnuwin32.sourceforge.net/) It was good and fast but now abandoned. No bash provided, but it's possible to use it from other packages. ezwinports (https://sourceforge.net/projects/ezwinports) My current favorite. Fast and works well. There is no bash provided with it, that can be a problem for some build systems. It's possible to use make from ezwinports and bash from Cygwin or MSYS2 as a workaround. MSYS 1.19 abandoned. Worked well but featured very old make (3.86 or so) MSYS2 (https://www.msys2.org/) Works well, second fastest solution after ezwinports. Good quality, package manager (pacman), all tooling available. I'd recommend this one. MinGW abandoned? There was usually MSYS 1.19 bundled with MinGW packages, that contained an old make.exe. Use mingw32-make.exe from the package, that's more up to date.

Note that you might not be able to select your environment. If the build system was created for Cygwin, it might not work in other environments without modifications (The make language is the same, but escaping, path conversion are working differently, $(realpath) fails on Windows paths, DOS bat files are started as shell scripts and many similar issues). If it's from Linux, you might need to use a real Linux or WSL. If the compiler is running on Linux, there is no point in installing make for Windows, because you'll have to run both make and the compiler on Linux. In the same way, if the compiler is running on Windows, WSL won't help, because in that environment you can only execute Linux tools, not Windows executables. It's a bit tricky!

我可以建议循序渐进的方法。

Visit GNUwin Download the Setup Program Follow the instructions and install GNUWin. You should pay attention to the directory where your application is being installed. (You will need it later1) Follow these instructions and add make to your environment variables. As I told you before, now it is time to know where your application was installed. FYI: The default directory is C:\Program Files (x86)\GnuWin32\. Now, update the PATH to include the bin directory of the newly installed program. A typical example of what one might add to the path is: ...;C:\Program Files (x86)\GnuWin32\bin