[英]Compile using Makefile on Windows
I want to compile my code using MakeFile in a Windows environment. 我想在Windows环境中使用MakeFile编译我的代码。 I have created a Makefile in Linux but don't have any idea how to create and run in Windows. 我在Linux中创建了一个Makefile,但不知道如何在Windows中创建和运行。 I have installed MinGW and also edited the environment variable path. 我安装了MinGW并编辑了环境变量路径。 I have tried running the Makefile like I was doing in a Linux environment, but I'm not able to run it. 我尝试像在Linux环境中那样运行Makefile,但是我无法运行它。 Can anyone please share any link. 任何人都可以分享任何链接。
This is my simple Makefile 这是我简单的Makefile
CC = g++
all: Exe
Exe : main.o Hello.o
$(CC) -o Exe main.o Hello.o
main.o: main.cpp
$(CC) -c main.cpp
Hello.o: Hello.cpp
$(CC) -c Hello.cpp
clean:
rm -rf *o main.o Hello.o
I am running it from the command prompt make MakeFile and every time it prompts with the message, makefile up to date . 我从命令提示符make MakeFile运行它,每次提示消息时, makefile都是最新的 。 It is not doing anything, not even generating an executable. 它没有做任何事情,甚至没有生成可执行文件。
The syntax is almost the same. 语法几乎相同。 It's really depend if you added specific command (like using find
, grep
, ...). 如果你添加了特定的命令(比如使用find
, grep
,......),这真的很有grep
。
You should add the error reported by make
command to your question. 您应该将make
命令报告的错误添加到您的问题中。 Without more information we cannot guess where is the problem 没有更多信息,我们无法猜出问题出在哪里
Edit: I did not understand that you do not find the make command. 编辑:我不明白你没有找到make命令。 The make
command is sometime named mingw32-make.exe
. make
命令有时命名为mingw32-make.exe
。 It's really depend which version and type of MinGW you installed 这真的取决于您安装的MinGW的版本和类型
Edit2: The command line to type is make
(or mingw32-make.exe
) and not make Makefile
Take a look at the man of make
Edit2:要键入的命令行是make
(或mingw32-make.exe
)而不是make Makefile
看看make
的人
In the clean:
section, do not use rm
, this command does not exist on Windows 在clean:
部分中,不要使用rm
,Windows上不存在此命令
Goto bin directory in MinGW and check whether you have a file named make.exe if you don't have it then rename mingw32-make.exe to make.exe 转到MinGW中的bin目录,如果没有,请检查是否有一个名为make.exe的文件,然后将mingw32-make.exe重命名为make.exe
As I remember normally make.exe is named mingw32-make.exe in the MinGW distribution, I don't know why they do so, but renaming it to make.exe can solve the problem in most of the cases. 我记得通常make.exe在MinGW发行版中命名为mingw32-make.exe,我不知道他们为什么会这样做,但是将它重命名为make.exe可以解决大多数情况下的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.