theOtherOne
theOtherOne

Reputation: 79

nmake makefile is not using inference rule

I am trying to get a target's object dependencies to use the inference/implicit rule. I get this error instead

NMAKE : fatal error U1073: don't know how to make 'interface1.obj' Stop. NMAKE : fatal error U1077: 'cd' : return code '0x2' Stop.

the last target to be called is

interface.dll: interface1.obj interface2.obj

I have inference rules in the makefile like this

.SUFFIXES: .c .cpp .obj

.c.obj:
      $(CC) $(CFLAGS) $<

.cpp.obj:
      $(CC) $(CFLAGS) $<

I have tried echoing tests after .c.obj is called and it never even gets there. It seems to not recognize the rules when trying to make the interface.obj I have also tried making the rule with paths like this

{$(SOURCE_DIR)}.c{$(BIN_PATH)}.obj:
    $(CC) $(CFLAGS) $<

I have succeeded in making a interface1.obj target and compiling the files one at a time, but I can't get the inference/implicit rule to get recognized and used.

Upvotes: 1

Views: 464

Answers (1)

theOtherOne
theOtherOne

Reputation: 79

{$(SOURCE_DIR)}.c{$(BIN_PATH)}.obj: 

means the object you are trying to make interface1.obj is located in $(BIN_PATH).
If you list your objects as interface1.obj then it will assume interface1.obj is in the current directory.

So you need to write the dependent object files as such: $(BIN_PATH)\\interface1.obj

vice versa, you could write the rule like {$(SOURCE_DIR)}.c{}.obj: and your dependent object like interface1.obj if they were indeed in the current directory.

same goes for the source files.

-Kelsey

Upvotes: 2

Related Questions