I have a project which has a makefile:
# a simple makefile
# Uncomment, if compression support is desired
#DCOMP=-DWITH_COMPRESSION
#ZLIB=-lz
#Compiler
CC=g++
# compiler switches
#CPPFLAGS=-g -I.
CPPFLAGS=-O -I.
CFLAGS=-O -I. $(DCOMP)
#LDFLAGS=-L/usr/local/lib
#libraries
LIBS= -lm $(ZLIB)
# Compilation rules
# target:source
%.o:%.c
$(CC) $(CFLAGS) -o $@ -c $<
%.o:%.cpp
$(CC) $(CPPFLAGS) -o $@ -c $<
# $@-target, $<-source
DNAME=f3dProjBasicNoComp12
PROGRAM=project
PROJ_OBJECTS= project.o f3d.o f3dGridLite.o
#the first (default)
all:$(PROGRAM)
project:$(PROJ_OBJECTS)
$(CC) $(LDFLAGS) -o $@ $(PROJ_OBJECTS) $(LIBS)
clean:
rm -f $(PROGRAM) *.o core* *.ppm
pack:
make clean
(cd .. && tar cvzf $(DNAME).tgz $(DNAME))
And I want to run it on Windows. The professor has said that I should compile it and run, but he did not tell me how can I do this on Windows. I have read that I should use nmake MakeFile, but than:
'nmake' is not recognized as an internal or external command,
operable program or batch file.
To run the application, I should use somethink like project -x somethink.obj
.
But because I cannot compile the makefile I cannot run the project.
Can you help me?
If your project is configured to use gcc/g++ (as in your example) then you should install mingw. After that you start the mingw shell, you go to your directory and type
make
(provided that you installed make when installing mingw) ormake -f <makefile name>
.NOTE: The windows path for
c:\mydir1\mydir2
is in mingw/c/mydir1/mydir2
. So you should reach your directory by typingcd /c/mydir1/mydir2
.If your project is configured to use Visual Studio (cl.exe compiler) you can:
"c:\Program Files\Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat"
(or your correspondingvcvars32.bat
)After you done this you go to your directory with
cd c:\mydir1\mydir2
and typenmake
(the make equivalent from visual studio package) ornmake /f <your makefile name>
.If you're required other toolchain to compile then you should follow specific steps. I remember that for using Borland compiler you only need to set the path to the
bcc32
executable.LATER EDIT:
In case the project uses unix specific procedure you should use cygwin (as mentioned in comments).
The easiest solution is to download minigw for windows with gcc. Take a look at: http://www.mingw.org/
1) You have to have Visual Studio installed
2) You have to run Visual Studio command prompt (you will find it in the Microsoft Visual Studio Start menu entry once you have it installed) and invoke
nmake
from there.