LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-16-2010, 12:47 PM   #1
catallergy
LQ Newbie
 
Registered: Mar 2010
Posts: 5

Rep: Reputation: 0
Static libraries vs shared Libraries


Hi

I have a third party static library (libSTATIC.a) that I cannot
recompile into a shared library. I want to create
a shared library (libSHARED.so) that uses the C functions in the static
library. Is it possible to do this?
In other words, when linking a C program with gcc by using the -shared flag, is it necessary that all all libraries invoked in the program
(even low level libraries such as libc for example) be available as
shared libraries as well?

Thanks a lot.
 
Old 03-16-2010, 01:03 PM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Yes, you can mix and match shared and static libraries in the same link command.

Under the circumstances, that's probably the best approach here. Just use your static library as-is; don't bother trying to convert it to a shared library.

IMHO .. PSM

PS:
"gcc --help" will show you all the command line options available to you.
 
Old 03-16-2010, 01:30 PM   #3
catallergy
LQ Newbie
 
Registered: Mar 2010
Posts: 5

Original Poster
Rep: Reputation: 0
Does the converse hold as well? In other words, if we have a
shared library libSHARED.so which we cannot modify, can we
create a static library libSTATIC.a which used the functions in
libSHARED.so? If yes, does gcc embed the code from libSHARED.so in
libSTATIC.a, or is it necessary that libSHARED.so be installed in the
system for the functions in libSTATIC.a to work properly at runtime?
 
  


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
Forcing static linking of shared libraries raghu_rao Linux - Newbie 8 01-14-2009 07:34 AM
Static variable sharing in shared libraries ristiisa Programming 13 10-20-2006 09:08 AM
shared libraries, dlopen and static member variables? (C/C++) Thinking Programming 2 12-19-2005 12:55 AM
compiling with shared and static libraries jinksys Programming 1 11-22-2003 04:54 AM
gaim trying to link static and shared libraries rose_bud4201 Linux - Software 0 09-28-2003 12:27 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:24 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