I want to compile my code using MakeFile in a Windows environment. I have created a Makefile in Linux but don't have any idea how to create and run in Windows. I have installed MinGW and also edited the environment variable path. I have tried running the Makefile like I was doing in a Linux environment, but I'm not able to run it. Can anyone please share any link.
This is my simple 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. 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
, ...).You should add the error reported by
make
command to your question. Without more information we cannot guess where is the problemEdit: I did not understand that you do not find the make command. The
make
command is sometime namedmingw32-make.exe
. It's really depend which version and type of MinGW you installedEdit2: The command line to type is
make
(ormingw32-make.exe
) and notmake Makefile
Take a look at the man ofmake
In the
clean:
section, do not userm
, this command does not exist on WindowsGoto 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.