I have 3 header files and 4 .c files in my c program,which are code1.h code1.c,code2.h code2.c,code3.h code3.c,and main.c
The main function was defined in main.c
The relationships between files are:
main.c includes code1.h, code1.h includes code2.h code2.h includes code3.h
I implemented a make file to compile and link them together.
But when the make file executed,it shows an error:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
here is my make file:
objects= main.o code1.o middle.o
executable:$(objects)
gcc-o $(objects) -o executable
main.o: main.c
gcc -c main.c
code1.o:code1.h code1.c
gcc -c code1.c
middle.o:code2.o code3.o
gcc -o code2.o code3.o -o middle.o
code2.o:code2.c code2.h
gcc -c code2.c
code3.o:code3.h code3.c
gcc -c code3.c