SE250:nmake
Makefiles on Windows
Makefiles in general
Here are some information and tutorials on the make tool.
- Make - a tutorial by Ben Yoshino (ben@wiliki.eng.hawaii.edu)
- Makefile Tutorial by Hector Urtubia
- Wikipedia information on Make
How to use NMAKE
I finally figured out how to use Visual Studio makefiles and thought people might find this useful.
- To invoke Windows Visual Studio command line make tool:
nmake
This assumes a file called Makefile already exists. If you're using another file, use:
nmake -f myMakefile
- Sample Makefile. To compile arraylist lab code:
<html> <body>
# NOTE: Lines starting with a hash (#) is a comment line.del arraylist.obj main.obj main.exe |
</body> </html>
cl.exe options
- /Fo<path> : Output the .obj file to a specified location. Similar to the -o option in GCC.
- e.g. cl main.c /Fo../main.obj to output the object file into main.c's parent folder.
- /Fe<path> : Output the .exe file to a specified location. Used in the same way as above and similar to the -o option in GCC.
- /c : Compile only, no linking. Similar to the -c option in GCC.
- e.g. cl /c arraylist.c /Fo../arraylist.obj to create an object file from the arraylist code and ouput it to the parent folder.
Type cl /help in the Visual Studio Command Prompt for more information.
nmake.exe options
- -f : Use when the filename of your makefile is not the default name "Makefile".
- e.g. nmake -f MyMakefile to compile your project.
- To clean up the output files use:
- nmake -f MyMakefile clean or nmake clean if your makefile is the default filename.
Type nmake /help in the Visual Studio Command Prompt for more information.
Reference
- nmake is the Visual Studio command line equivalent of make.
- cl is the Visual Studio command line equivalent of gcc.