I have to run these 4 commands on the terminal each time I want to execute the program using libraries.
The lines are
cc -m32 -c mylib.c
ar -rcs libmylib.a mylib.o
cc -m32 -c prog.c
cc -m32 prog.o -L. -lmylib
./a.out
How do I make a makefile for the above commands and run it? A detailed procedure would be appreciated. Thanks.
Edit: Here is the solution:
a.out: prog.o libmylib.a
cc prog.o -L. -lmylib
prog.o: prog.c mylib.h
libprint_int.a: mylib.o
ar -rcs libmylib.a mylib.o
print_int.o: mylib.c mylib.h
clean:
rm a.out prog.o libmylib.a mylib.o
This gave an error on line 2 because I used spaces instead of tab.