LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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, 07: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 08:14 AM.
 
Old 05-15-2008, 12: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, 06: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, 11:01 AM   #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



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

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:42 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
Open Source Consulting | Domain Registration