In make, you want to define the targets you want to be created or brought up to date. Here, your
all target depends on the source files, which is wrong: you don’t want make to create the source files. The source files already exist. You want make to create the object files, in the
all rule should be:
all: bin/main1.o bin/main2.o
Now, you have to teach make how to create a
bin/xxx.o from a
You can do that by writing a pattern rule, which is a template that make can use to figure out how to build things. For example:
bin/%.o : src/%.c gcc -Wall -fpic -c $< -o [email protected]
That’s it! See the manual for more information.
CLICK HERE to find out more related problems solutions.