How to generate object files in the build directory? - TagMerge
1How to generate object files in the build directory?How to generate object files in the build directory?

How to generate object files in the build directory?

Asked 10 months ago
1
1 answers

Searching would definitely find you a lot of examples and information on this.

First tell make what objects you want to build; change your setting of OBJS to this:

# object file list
OBJS := $(SRCS:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.o)

Then tell make how to build it; change your pattern rule for building objects to this:

$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
        @mkdir -p $(@D)
        $(CC) $(CFLAGS) $(INC_FLAGS) -c $< -o $@

Source: link

Recent Questions on c

    Programming Languages