LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices



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

Rep: Reputation: 15
How to make shared library form static libraries (pjsip)


Hello!

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:

Code:
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 libpjsipDll.so.1.0.1  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 libpjsipDll.so.1.0.1
Am I missing something? Is there some other way to do what I want?

Regards,

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

Rep: Reputation: 0
In case you haven't read:
http://www.pjsip.org/pjlib/docs/html...ll__target.htm

Regards
 
0 members found this post helpful.
Old 04-09-2011, 07:27 PM   #3
Marko-M
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, 12:01 PM   #4
rstinejr
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 http://www.pjsip.org/pjlib/docs/html...ll__target.htm 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(http://code.google.com/p/csipsimple/), although what's going on there is cluttered up quite a bit by the Android NDK macros.
 
  


Reply


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 12:54 PM
Making a static library from a given shared library vro Programming 1 07-27-2007 05:07 PM
LINUX - linking archive (static library) with shared (dynamic) library gurkama Programming 5 03-05-2007 12:11 AM
howto compile bin with my library using all-static and shared linked standart library stpg Programming 4 06-29-2004 05:20 AM
compiling with shared and static libraries jinksys Programming 1 11-22-2003 05:54 AM


All times are GMT -5. The time now is 08:39 PM.

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