Tomi
Tomi

Reputation: 53

how to create shared lib from objects or static lib

I would like to get shared libs for dynamic linking.

I have object files and static files, but no shared lib files.

Can I convert somehow them to create shared lib?

Upvotes: 1

Views: 110

Answers (1)

thejh
thejh

Reputation: 45568

See http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html.

Basically, you create a shared library like this:

gcc -shared -Wl,-soname,libfoo.so.1 -o libfoo.so.1.0.1 file1.o file2.o file3.o ...

The generated file will be named libfoo.so.1.0.1. However, you have to make sure that the *.o files were created with the -fPIC flag for position independent code or it won't work.

Upvotes: 2

Related Questions