Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 05-15-2008, 07:29 AM   #1
Registered: Aug 2005
Location: Slovenia
Distribution: Fedora, Ubuntu
Posts: 69

Rep: Reputation: 15
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?


Last edited by Rostfrei; 05-15-2008 at 08:14 AM.
Old 05-15-2008, 12:55 PM   #2
LQ Newbie
Registered: May 2008
Posts: 2

Rep: Reputation: 0
In case you haven't read:

0 members found this post helpful.
Old 04-09-2011, 06:27 PM   #3
LQ Newbie
Registered: Apr 2011
Posts: 5

Rep: Reputation: 2
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!
1 members found this post helpful.
Old 08-30-2011, 11:01 AM   #4
LQ Newbie
Registered: Aug 2011
Posts: 2

Rep: Reputation: Disabled
Unhappy 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.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
shared to static library ofada Programming 2 07-08-2009 11:54 AM
Making a static library from a given shared library vro Programming 1 07-27-2007 04:07 PM
LINUX - linking archive (static library) with shared (dynamic) library gurkama Programming 5 03-04-2007 11:11 PM
howto compile bin with my library using all-static and shared linked standart library stpg Programming 4 06-29-2004 04:20 AM
compiling with shared and static libraries jinksys Programming 1 11-22-2003 04:54 AM > Forums > Non-*NIX Forums > Programming

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

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration