how do you create multipleos?

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 bin directory.

So, your 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 src/xxx.c.

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]

The $< and [email protected] are automatic variables that make will set for your recipe before trying to run it, for each target you want to build.

That’s it! See the manual for more information.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top