My project architecture :
project_folder/
|--bin/
|--src/
| |-----module1/
| | |----> module1.c
| | |----> module1.h
| | |----> module1.o
| | |----> makefile
| |-----module2/
| | |----> module2.c
| | |----> module2.h
| | |----> module2.o
| | |----> makefile
|-- makefile
|-- main.c
When I make my project It correctly builds the modules of my project and then when I want to compile the whole project I have undefined reference to modules' functions.
I think the error comes from my CC command in my head makefile so here is my makefile :
export CC = gcc
PACKAGES = module1 module2
MAIN = main.c
EXEC = bin
all: $(PACKAGES) $(EXEC)
$(PACKAGES):
@$(MAKE) $(MAKECMDGOALS) -C $@
$(EXEC): $(MAIN)
$(CC) $(MAIN) -o $(EXEC)
.PHONY: all clean $(PACKAGES)
clean: $(PACKAGES)
Error is :
/usr/bin/ld: /project_folder/main.c:line undefined reference to `module1_fct1`
Do y have any advice ?