Compile linux .a and .so file

Compile linux .a and .so file
now, I got main.c, sub.h, sub.c, util.h, util.c.

how to compile main.bin?
#gcc -o main.bin *.c

how to compile sub.a?
#gcc -c -o sub.o sub.c
#ar r sub.a sub.o

how to compile sub.so?
 #gcc -fpic -c -o sub.o sub.c
#gcc -shared -o sub.so sub.o

here is the original url

你可能感兴趣的:(Compile linux .a and .so file)