Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating .so and .a in UNIX

Tags:

unix

How to create a .so and .a file in UNIX. Do we have any standard utility for it?

like image 763
Sachin Chourasiya Avatar asked Oct 30 '09 05:10

Sachin Chourasiya


2 Answers

*.a - archive library to create it compile your sources:

gcc -c -o foo.o foo.c
gcc -c -o boo.o boo.c

ar -rsc yourlib.a foo.o boo.o

so - position independent code shared library

gcc -fPIC -shared  -soname,libfoo.so.1 -o libfoo.so.1.0 foo.c boo.c
like image 71
bua Avatar answered Oct 08 '22 22:10

bua


#create shared library
gcc -Os -fPIC -c test.c
gcc -shared  test.so test.o 


#create static library
gcc -Os -c test.c
ar rcs test.a test.o
like image 40
pierrotlefou Avatar answered Oct 08 '22 22:10

pierrotlefou