[C API] Missing UDEFS for simulator code in common.mk

The rule compiling simulator projects is missing the use of the UDEFS variable which is used in compiling target projects. This can lead to projects compiling for targets but not for the simulator.

More precisely:

$(OBJDIR)/pdex.${DYLIB_EXT}: OBJDIR
	$(SIMCOMPILER) $(DYLIB_FLAGS) -lm -DTARGET_SIMULATOR=1 -DTARGET_EXTENSION=1 $(INCDIR) -o $(OBJDIR)/pdex.${DYLIB_EXT} $(SRC)

should be

$(OBJDIR)/pdex.${DYLIB_EXT}: OBJDIR
	$(SIMCOMPILER) $(DYLIB_FLAGS) -lm -DTARGET_SIMULATOR=1 -DTARGET_EXTENSION=1 $(UDEFS) $(INCDIR) -o $(OBJDIR)/pdex.${DYLIB_EXT} $(SRC)
2 Likes

Thanks for bringing this up. I tried to describe the issue here but I think I ended up just confusing myself :grimacing:

Oh man, my bad... I should have search a little bit better before posting the duplicate.

Wasn't my intention to say you should have searched more! I think having multiple posts about this is fine. Looking back at my original post, I'm not sure if I explained the solution correctly, so having multiple eyes on this is good :slight_smile:

1 Like

For a temporary fix without modifying common.mk, you can add this to your makefile:

DYLIB_FLAGS += $(UDEFS)

Of course, once they fix it in the SDK you will have duplicate defines.