Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


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

Rep: Reputation: 0
Static libraries vs shared Libraries


I have a third party static library (libSTATIC.a) that I cannot
recompile into a shared library. I want to create
a shared library ( 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
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.


"gcc --help" will show you all the command line options available to you.
Old 03-16-2010, 01:30 PM   #3
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 which we cannot modify, can we
create a static library libSTATIC.a which used the functions in If yes, does gcc embed the code from in
libSTATIC.a, or is it necessary that be installed in the
system for the functions in libSTATIC.a to work properly at runtime?


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
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 > Forums > Linux Forums > Linux - Newbie

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