3

我想在 Windows 环境中使用 MakeFile 编译我的代码。我在 Linux 中创建了一个 Makefile,但不知道如何在 Windows 中创建和运行。我已经安装了 MinGW 并且还编辑了环境变量路径。我曾尝试像在 Linux 环境中那样运行 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

我从命令提示符make MakeFile运行它,每次它提示消息时,makefile up to date。它没有做任何事情,甚至没有生成可执行文件。

4

2 回答 2

4

语法几乎相同。这真的取决于你是否添加了特定的命令(比如使用find, grep, ...)。

您应该将make命令报告的错误添加到您的问题中。没有更多信息,我们无法猜测问题出在哪里

编辑:我不明白你没有找到 make 命令。该make命令有时被命名为mingw32-make.exe. 这真的取决于你安装的 MinGW 的版本和类型

Edit2: 要键入的命令行是make(或mingw32-make.exe)而不是make Makefilemake

在该clean:部分中,不要使用rm,此命令在 Windows 上不存在

于 2013-01-04T14:27:49.513 回答
2

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
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.

于 2013-01-04T14:31:28.827 回答