Target name MUST start at the beginning of the line. Spaces are allowed (but not requred) around the colon that separates target and dependents. Commands in description block MUST be preceded with a SPACE character; nmake will otherwise complain with message makefile(.) : fatal error U1034: syntax error : separator missing.

Compiler creates obj file and automatically invokes the linker after compiling unless the /c option is used. Linker creates executable. Upon nmake call, we have following files in our project directory:

..\HelloWorld\main.cpp
main.exe
main.obj
makefile
setenv.bat

Ok, we got binary but let us tidy things a bit and let us see how to involve header files. By default, compiler gives binary a default name using the base name of the first source or object file specified on the command line. I want binary to be named as "helloworld.exe" and want it to be placed in "..\HelloWorld\bin\x86" directory. OBJ files should be put in the intermediate directory "..\HelloWorld\intermediate\x86". I want my main function to be in "..\HelloWorld\src\main.cpp" and to use some function declared in header "..\HelloWorld\include\printx.h" and defined in "..\HelloWorld\src\printx.cpp". Furthermore, makefile should be in "..\HelloWorld\build". Project structure before nmake call should be:

We can avoid repeating description blocks for each OBJ file by using inference rules. They are generic description blocks that define rules of how files with one extension are converted into files with the same name but different extensions. These rules are applied when resolving dependants. In the following makefile, EXE depends on OBJ files and inference rule defines how are OBJ files generated from CPP files:

Here is yet another example of a simple makefile which compiles single main.cpp into main.obj and then links obj file to myapp.exe. Note that full names (with extensions) of source, object and binary files are used as target and dependent names: