LinuxQuestions.org
Support LQ: Use code LQCO20 and save 20% on CrossOver Office
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
 
LinkBack Search this Thread
Old 11-18-2009, 05:18 AM   #1
hanumaan
LQ Newbie
 
Registered: Sep 2009
Posts: 2

Rep: Reputation: 0
How can we convert a dynamic library (filename.so) to a static library (filename.a).


How can we convert a dynamic library (filename.so) to a static library (filename.a) using gnu gcc . Can we get a static library form a dynamic library . I saw a few post in which the conversion form a static library to a dynamic library is mentioned but, unfortunately, not the other way.

Last edited by hanumaan; 11-19-2009 at 01:00 AM.
 
Old 11-18-2009, 07:41 AM   #2
rylan76
Senior Member
 
Registered: Apr 2004
Location: Potchefstroom, South Africa
Distribution: FC11 2.6.29.4-167.fc11.i686.PAE
Posts: 1,370

Rep: Reputation: 69
Not sure, but I think you can use GNU "ar" (google it) and if you pass it the correct parameters you can take a set of object files (.o files) produced by GCC and either output a static, or dynamic library consisting of them.
 
Old 11-18-2009, 11:02 AM   #3
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,434

Rep: Reputation: 303Reputation: 303Reputation: 303Reputation: 303
I think you'd use ar to archive the original *.o object files. For a *.so file you'd need to extract the *.o files from the *.so lib first.
 
Old 11-19-2009, 11:26 PM   #4
hanumaan
LQ Newbie
 
Registered: Sep 2009
Posts: 2

Original Poster
Rep: Reputation: 0
I don't think that ar(an archiving tool) is the right tool for extracting *.o files from a *.so file. If you run the 'file' command on a *.so library, it gives "ELF 32-bit LSB shared object" as output. This shows that dynamic libraries (*.so files) are similar to object files (*.o files) and hence it is unlikely that an archiving tool, such as ar, will be able to understand it.
However there may be a different tool which can do the conversion. Or may be it is too impractical (Just as a conversion from form a *.o file to a *.cc file is ).

Last edited by hanumaan; 11-20-2009 at 05:14 AM. Reason: gramatical error
 
Old 11-20-2009, 12:07 AM   #5
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: Slackware64 13.37, Kubuntu 10.04
Posts: 2,941

Rep: Reputation: Disabled
You'll probably have to decompile the shared library because it's already linked. That means information required for the .o is lost because the parts become connected to the whole. In a sense, a shared library is the same as a binary except it's created under the assumption that it won't be executed directly (in most cases, the main exception being ld.*.so.)
Kevin Barry

Last edited by ta0kira; 11-20-2009 at 12:10 AM.
 
1 members found this post helpful.
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change the filename of a library dependency? thatbloke Linux - Software 1 01-29-2009 02:29 PM
Convert static library (Filename.a) to dynamic shared object (filename.so) afx2029 Linux - Software 4 08-17-2007 06:07 AM
LINUX - linking archive (static library) with shared (dynamic) library gurkama Programming 5 03-04-2007 11:11 PM
Linking a static library to a dynamic one delta4s Programming 2 09-28-2006 01:24 AM
extracting a library file named filename.1.2.... Tavassoli Linux - Software 1 06-15-2006 07:29 AM


All times are GMT -5. The time now is 09:31 AM.

Main Menu
 
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
Open Source Consulting | Domain Registration