Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a shared object file from static library

How to create a shared object file from a static library? I am using Cygwin.

Is the following syntax correct?

gcc -shared -o libexample.so libexample.a
like image 354
Sureshkumar Menon Avatar asked Jun 07 '11 10:06

Sureshkumar Menon


1 Answers

gcc -shared -o libexample.so -Wl,--whole-archive libexample.a

Pay attention that often you'll want the objects combined in your .so to be compiled as PIC, something you don't often want for a static library.

like image 83
AProgrammer Avatar answered Oct 04 '22 03:10

AProgrammer