Reputation: 63
here is my problem
SOURCES_FUNCTIONS=cJSON.c parallelisationUtilities.c
$(BUILD_DIR)/%.o : $(SOURCE_DIR)/%.c
$(CC) $(CFLAGS) -c $< -o $@ $(IFLAGS)
make: *** Aucune règle pour fabriquer la cible « parallelisationUtilities.o », nécessaire pour « build/mainFunction ». Arrêt
By placing parallelisationUtilities.c before cJSON.c in SOURCES_FUNCTIONS, i get the same error with cJSON.o. Fore sure, there are no missing files..
++ Michael
Upvotes: 0
Views: 533
Reputation: 63
$(BUILD_DIR)/$(EXEC_MAINFUNCTION): $(patsubst %.o,$(BUILD_DIR)/%.o,$(OBJECTS_FUNCTIONS)) $(patsubst %.o,$(BUILD_DIR)/%.o,$(OBJECTS_FUNCTIONS_NOT_TO_CLEAN)) $(patsubst %.o,$(BUILD_DIR)/%.o,$(OBJECT_MAINFUNCTION))
$(CC) $^ -o $@ $(LDFLAGS)
$(BUILD_DIR)/%.o : $(SOURCE_DIR)/%.c
$(CC) $(CFLAGS) -c $< -o $@ $(IFLAGS)
Thanks a lot Mad!
Upvotes: 0
Reputation: 100781
You didn't show enough of the makefile: you left out the most critical part which is what target is listing the object files as prerequisites.
I'll bet you have something like this:
xxxx: $(BUILD_DIR)/$(SOURCES_FUNCTIONS:.c=.o)
That's wrong, because it only adds $(BUILD_DIR)
to the first file. The expansion of $(SOURCES_FUNCTIONS:.c=.o)
gives:
xxxx: $(BUILD_DIR)/cJSON.o parallelisationUtilities.o
You need to use something like this:
xxxx: $(patsubst %.c,$(BUILD_DIR)/%.o,$(SOURCES_FUNCTIONS))
so that the BUILD_DIR
prefixes all the files.
Upvotes: 1