-   Programming (
-   -   How to make shared library form static libraries (pjsip) (

Rostfrei 05-15-2008 07:29 AM

How to make shared library form static libraries (pjsip)

I'm using SIP library (pjsip) that is compiled into multiple static libraries. It doesn't have an option to compile it as shared libraries so they are compiles as static libraries by default. I have some small wrapper code that is calling all needed functions in the static libraries (from C++ wrapper as extern "C" some_pjsip_function_name() ). There is no main() function in it. Now, I would like to build this wrapper code as shared library. I expected that all needed symbols from static libraries will be linked into shared library, but this is not the case. The shared library generated is too small (40 K or so).

My steps were:


g++ -c -fPIC -I "../pjsip/include/" -I "../pjlib/include" -I "../pjlib-util/include" -I "../pjmedia/include" -I "../pjnath/include" -shared -o pjsipDll.o pjsipDll.cpp

g++ -shared -Wl -o  pjsipDll.o -L. -lpjsua-i686-pc-linux-gnu -lpjsip-ua-i686-pc-linux-gnu -lpjsip-simple-i686-pc-linux-gnu -lpjsip-i686-pc-linux-gnu -lpjmedia-codec-i686-pc-linux-gnu -lpjmedia-i686-pc-linux-gnu -lpjnath-i686-pc-linux-gnu -lpjlib-util-i686-pc-linux-gnu -lresample-i686-pc-linux-gnu -lmilenage-i686-pc-linux-gnu -lsrtp-i686-pc-linux-gnu -lgsmcodec-i686-pc-linux-gnu -lspeex-i686-pc-linux-gnu -lilbccodec-i686-pc-linux-gnu -lportaudio-i686-pc-linux-gnu -lpj-i686-pc-linux-gnu -lm -lnsl -lrt -lpthread  -lssl -lcrypto

I get:
-rwxr-xr-x 1 foo foo  38238 2008-05-15 14:24

Am I missing something? Is there some other way to do what I want?


nadin 05-15-2008 12:55 PM

In case you haven't read:


Marko-M 04-09-2011 06:27 PM

If anyone stumbles here, I've wrote two howtos on my site about C/C++ library programming on Linux (creating and using shared and static libraries).

Here are the links:

C/C++ library programming on Linux Part one: Static libraries

C/C++ library programming on Linux Part two: Dynamic libraries

Good luck!

rstinejr 08-30-2011 11:01 AM

No Linux info on pjsip page
With respect to Nadin, there is nothing at that will help in creating shared linux library.

Marko-M has excellent background info. For a working example that creates shared libraries for Android, you might also check out the CSipSimple project(, although what's going on there is cluttered up quite a bit by the Android NDK macros.

All times are GMT -5. The time now is 01:11 PM.