NMake Template Rules

Hi, I decided to try and learn how to build programs through the command line and make files instead of relying on Visual Studio to do this for me. After familiarizing myself with the compilation process into .obj files and binding, I switched to NMake. I wrote the main make file to try to compile the source files located in several folders into .obj files, link each folder of .obj files to .lib files, and then link the .lib files to the .exe file.

CC=cl /c /EHsc /Fo LIB=lib /OUT: LINKER=link /OUT: EXEC_NAME=Test.exe DEL=del MAKE=nmake OUT=.\out all: $(OUT)\*.lib $(LINKER)$(EXEC_NAME) *.lib clean: $(DEL) $(OUT) rebuild: $(MAKE) clean $(MAKE) all $(OUT)%.lib: $(OUT)\%\*.obj $(LIB)%.lib $(OUT)%\*.obj %(OUT)\%\: $(CC)$(OUT)\%\ .\%\*.cpp 

When I try to run it with nmake all , it tells me: NMAKE : fatal error U1073: don't know how to make '.\out\*.lib'

Thanks in advance.

+6
source share
1 answer

This question was understandably ignored for a year and a half, but recently attracted 4 upvotes.

No question asked, but implied question: why nmake n't nmake follow the% -pattern rules in my makefile?

Answer to this question: MS nmake does not support the% -pattern rules. The MS nmake and its output rules are easy to find.

GNU make and some other support tools are % - pattern rules . The makefile will also fail in GNU make due to obvious errors.

+4
source

Source: https://habr.com/ru/post/927096/


All Articles