Windows 7 - 'make' 不是内部或外部命令,也不是可运行的程序或批处理文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23723364/
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
Windows 7 - 'make' is not recognized as an internal or external command, operable program or batch file
提问by programmer
I have Windows 7 and tried to use the 'make' command but 'make' is not recognized as an internal or external command.
我有 Windows 7 并尝试使用“make”命令,但“make”未被识别为内部或外部命令。
I did Start -> cmd -> run -> make
, which outputs:
我做了Start -> cmd -> run -> make
,输出:
'make' is not recognized as an internal or external command,operable program or batch file.
'make' 不是内部或外部命令,也不是可运行的程序或批处理文件。
Then I typed 'mingw32-make' instead of 'make' (Start -> cmd -> run -> mingw32-make
) and I get the same output:
然后我输入 'mingw32-make' 而不是 'make' ( Start -> cmd -> run -> mingw32-make
) 并得到相同的输出:
'mingw32-make' is not recognized as an internal or external command,operable program or batch file.
'mingw32-make' 不是内部或外部命令,也不是可运行的程序或批处理文件。
What shall I do next in order to fix this problem?
为了解决这个问题,我下一步该怎么做?
采纳答案by kebs
Your problem is most likely that the shell does not know where to find your make
program. If you want to use it from "anywhere", then you must do this, or else you will need to add the full path each time you want to call it, which is quite cumbersome. For instance:
您的问题很可能是 shell 不知道在哪里可以找到您的make
程序。如果你想从“任何地方”使用它,那么你必须这样做,否则你每次要调用它时都需要添加完整路径,这很麻烦。例如:
"c:\program files\gnuwin32\bin\make.exe" option1=thisvalue option2=thatvalue
This is to be taken as an example, it used to look like something like this on XP, I can't say on W7. But gnuwin32used to provide useful "linux-world" packages for Windows. Check details on your provider for make.
举个例子,它曾经在XP上看起来像这样,我不能在W7上说。但是gnuwin32曾经为 Windows 提供有用的“linux-world”包。检查您的供应商的详细信息以了解制造商。
So to avoid entering the path, you can add the path to your PATH
environment variable. You will find this easily.
To make sure it is registered by the OS, open a console (run cmd.exe
) and entering $PATH
should give you a list of default pathes. Check that the location of your make
program is there.
因此,为了避免输入路径,您可以将路径添加到您的PATH
环境变量中。你会很容易找到这个。为了确保它被操作系统注册,打开一个控制台(运行cmd.exe
)并输入$PATH
应该给你一个默认路径的列表。检查您的make
程序的位置是否在那里。
回答by user61871
In Windows10, I solved this issue by adding "C:\MinGW\bin" to Path then called it using MinGW32-makenot make
在 Windows10 中,我通过将 "C:\MinGW\bin" 添加到 Path 然后使用MinGW32-makenot make调用它来解决这个问题
回答by Foad
- First make sure you have MinGW installed.
- From MinGW installation manager check if you have the
mingw32-make
package installed. - Check if you have added the MinGW bin folder to your PATH. type
PATH
in your command line and look for the folder. Or on windows 10 go toControl Panel\System and Security\System --> Advanced system settings --> Environment Variables --> System Variables
findPath
variable, select,Edit
and check if it is there. If not just add it! - As explained here, create a new file in any of your PATH folders. For example create
mingwstartup.bat
in the MinGW bin folder. write the linedoskey make=mingw32-make.exe
inside, save and close it. - open Registry Editor by running
regedit
. As explained hereinHKEY_LOCAL_MACHINE
orHKEY_CURRENT_USER
go to\Software\Microsoft\Command Processor
right click on the right panelNew --> Expandable String Value
and name itAutoRun
. double click and enter the path to your .bat file as the Value data (e.g."C:\MinGW\bin\mingwstartup.bat"
) the result should look like this:
- 首先确保你已经安装了 MinGW。
- 从 MinGW 安装管理器检查您是否
mingw32-make
安装了软件包。 - 检查您是否已将 MinGW bin 文件夹添加到您的 PATH。键入
PATH
您的命令行和查找的文件夹。或者在 Windows 10 上Control Panel\System and Security\System --> Advanced system settings --> Environment Variables --> System Variables
查找Path
变量,选择Edit
并检查它是否存在。如果没有就添加它! - 正如解释在这里,创建您的任何路径文件夹中的一个新的文件。例如
mingwstartup.bat
在 MinGW bin 文件夹中创建。在doskey make=mingw32-make.exe
里面写一行,保存并关闭它。 - 通过运行打开注册表编辑器
regedit
。正如解释这里的HKEY_LOCAL_MACHINE
还是HKEY_CURRENT_USER
去\Software\Microsoft\Command Processor
右键单击右侧面板上New --> Expandable String Value
,并将其命名AutoRun
。双击并输入 .bat 文件的路径作为值数据(例如"C:\MinGW\bin\mingwstartup.bat"
),结果应如下所示:
now every time you open a new terminal make
command will run the mingw32-make.exe
. I hope it helps.
现在每次打开一个新的终端make
命令都会运行mingw32-make.exe
. 我希望它有帮助。
回答by user3649944
'make' is a command for UNIX/Linux. Instead of it, use 'nmake' command in MS Windows. Or you'd better use an emulator like CYGWIN.
'make' 是 UNIX/Linux 的命令。取而代之的是,在 MS Windows 中使用“nmake”命令。或者你最好使用像 CYGWIN 这样的模拟器。
回答by tripleee
This is an old question, but none of the answers here provide enough context for a beginner to choose which one to pick.
这是一个古老的问题,但这里的答案都没有为初学者提供足够的背景来选择选择哪个。
What is make
?
什么是make
?
make
is a traditional Unix utility which reads a Makefile
to decide what programs to run to reach a particular goal. Typically, that goal is to build a single piece of software; but make
is general enough to be used for various other tasks, too, like assembling a PDF from a collection of TeX source files, or retrieving the newest versions of each of a set of web pages.
make
是一个传统的 Unix 实用程序,它读取 aMakefile
来决定运行哪些程序以达到特定目标。通常,该目标是构建单个软件;但make
也足以用于各种其他任务,例如从一组 TeX 源文件中组装 PDF,或检索一组网页中的每一个的最新版本。
Besides encapsulating the steps to reach an individual target, make
reduces processing time by avoiding to re-execute steps which are already complete. It does this by comparing time stamps between dependencies; if A depends on B but A is newer than B, there is no need to make A
. Of course, in order for this to work properly, the Makefile
needs to document all such dependencies.
除了封装达到单个目标的步骤之外,还make
可以通过避免重新执行已经完成的步骤来减少处理时间。它通过比较依赖项之间的时间戳来实现这一点;如果 A 依赖于 B 但 A 比 B 新,则没有必要make A
。当然,为了使其正常工作,Makefile
需要记录所有此类依赖项。
A: B
commands to produce A from B
Notice that the indentation needs to consist of a literal tab character. This is a common beginner mistake.
请注意,缩进需要由文字制表符组成。这是初学者常见的错误。
Common Versions of make
常见版本 make
The original make
was rather pedestrian. Its lineage continues to this day into BSD make
, from which nmake
is derived. Roughly speaking, this version provides the make
functionality defined by POSIX, with a few minor enhancements and variations.
原来make
是相当行人。它的血统一直延续到今天进入BSD make
,从中nmake
推导。粗略地说,这个版本提供了make
POSIX 定义的功能,并有一些小的增强和变化。
GNU make
, by contrast, significantly extendsthe formalism, to the point where a GNU Makefile
is unlikely to work with other versions (or occasionally even older versions of GNU make
). There is a convention to call such files GNUmakefile
instead of Makefile
, but this convention is widely ignored, especially on platforms like Linux where GNU make
is the de factostandard make
.
make
相比之下,GNU显着扩展了形式主义,以至于 GNUMakefile
不太可能与其他版本(或者有时甚至是旧版本的 GNU make
)一起工作。有一个约定来调用这样的文件GNUmakefile
而不是Makefile
,但是这个约定被广泛忽略,特别是在像 Linux 这样的平台上,其中 GNUmake
是事实上的标准make
。
Telltale signs that a Makefile
uses GNU make
conventions are the use of :=
instead of =
for variable assignments (though this is not exclusively a GNU feature) and a plethora of functions like $(shell ...)
, $(foreach ...)
, $(patsubst ...)
etc.
蛛丝马迹,一个Makefile
使用GNUmake
约定使用的:=
,而不是=
为变量赋值(尽管这不完全是一个GNU功能)和类似的功能过多$(shell ...)
,$(foreach ...)
,$(patsubst ...)
等。
So Which Do I Need?
那么我需要哪个?
Well, it really depends on what you are hoping to accomplish.
嗯,这真的取决于你希望完成什么。
If the software you are hoping to build has a vcproj
file or similar, you probably want to use that instead, and not try to use make
at all.
如果您希望构建的软件有vcproj
文件或类似文件,您可能想改用它,而根本不要尝试使用make
。
In the general case, MinGW make
is a Windows port of GNU make
for Windows, It should generally cope with any Makefile
you throw at it.
在一般情况下,MinGWmake
是 GNU make
for Windows的 Windows 端口,它通常应该可以处理Makefile
你扔给它的任何东西。
If you know the software was written to use nmake
and you already have it installed, or it is easy for you to obtain, maybe go with that.
如果您知道该软件是为使用nmake
而编写的并且您已经安装了它,或者您很容易获得它,那么也许可以使用它。
You should understand that if the software was not written for, or explicitly ported to, Windows, it is unlikely to compile without significant modifications. In this scenario, getting make
to run is the least of your problems, and you will need a good understanding of the differences between the original platform and Windows to have a chance of pulling it off yourself.
您应该明白,如果该软件不是为 Windows 编写或明确移植到 Windows 的,则在没有重大修改的情况下不太可能进行编译。在这种情况下,make
运行是您遇到的最少问题,您需要很好地了解原始平台和 Windows 之间的差异,以便有机会自己解决问题。
In some more detail, if the Makefile
contains Unix commands like grep
or curl
or yacc
then your system needs to have those commands installed, too. But quite apart from that, C or C++ (or more generally, source code in any language) which was written for a different platform might simply not work - at all, or as expected (which is often worse) - on Windows.
更详细地说,如果Makefile
包含 Unix 命令,例如grep
或curl
,yacc
那么您的系统也需要安装这些命令。但除此之外,为不同平台编写的 C 或 C++(或更一般地说,任何语言的源代码)可能根本无法在 Windows 上运行 - 根本无法运行,或者按预期(通常更糟)运行。
回答by Jerry Chong
If you already have MinGWinstalled in Windows 7, just simply do the following:
如果您已经在 Windows 7 中安装了MinGW,只需执行以下操作:
- Make another copy of
C:\MinGW\bin\mingw32-make.exe
file in the same folder. - Rename the file name from
mingw32-make.exe
tomake.exe
. - Run makecommand again.
C:\MinGW\bin\mingw32-make.exe
在同一文件夹中制作另一个文件副本。- 将文件名从 重命名
mingw32-make.exe
为make.exe
. - 再次运行make命令。
Tested working in my laptop for above steps.
在我的笔记本电脑上测试了上述步骤。
回答by Toothless
I am using windows 8. I had the same problem. I added the path "C:\MinGW\bin" to system environment variable named 'path' then it worked. May be, you can try the same. Hope it'll help!
我使用的是 Windows 8。我遇到了同样的问题。我将路径“C:\MinGW\bin”添加到名为“path”的系统环境变量中,然后它就起作用了。可能是,你也可以试试。希望它会有所帮助!
回答by mins
Search for make.exe using the search feature, when found, note down the absolute path to the file. You can do that by right-clicking on the filename in the search result and then properties, or open location folder (not sure of the exact wording, I'm not using an English locale).
使用搜索功能搜索 make.exe,找到后记下文件的绝对路径。您可以通过右键单击搜索结果中的文件名,然后单击属性,或打开位置文件夹(不确定确切的措辞,我没有使用英语区域设置)来完成此操作。
When you open the command line console (cmd) instead of typing make
, type the whole path and name, e.g. C:\Windows\System32\java
(this is for java...).
当您打开命令行控制台 (cmd) 而不是键入 时make
,请键入整个路径和名称,例如C:\Windows\System32\java
(这是用于 java...)。
Alternatively, if you don't want to provide the full path each time, then you have to possibilities:
或者,如果您不想每次都提供完整路径,那么您必须有以下可能性:
- make
C:\Windows\System32\
the current working directory, usingcd
at cmd level. - add
C:\Windows\System32\
to you PATH environment variable.
- 创建
C:\Windows\System32\
当前工作目录,cd
在 cmd 级别使用。 - 添加
C:\Windows\System32\
到您的 PATH 环境变量中。
Refs:
参考:
回答by Tushar
As other answers already suggested, you must have MinGW
installed. The additional part is to add the following two folders to the PATH
environment variable.
正如其他答案已经建议的那样,您必须已MinGW
安装。额外的部分是将以下两个文件夹添加到PATH
环境变量中。
- C:\MinGW\bin
- C:\MinGW\msys\1.0\bin
- C:\MinGW\bin
- C:\MinGW\msys\1.0\bin
Obviously, adjust the path based on where you installed MinGW. Also, dont forget to open a new command line terminal.
显然,根据您安装 MinGW 的位置调整路径。另外,不要忘记打开一个新的命令行终端。
回答by shubham ghosh
use mingw32-make instead of cmake in windows
在 Windows 中使用 mingw32-make 而不是 cmake