LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 09-25-2006, 03:27 AM   #1
delta4s
LQ Newbie
 
Registered: Aug 2005
Posts: 3

Rep: Reputation: 0
Linking a static library to a dynamic one


I have a set of .a libraries which I want to link into my .so library.
I want to do this because the user of my dynamic library shouldnt have to link to the .a libraries in his code. Instead he should link to my library and get all the libs.

When I linked the .a directly into the .so, the lib built fine, but any executables that I built using this .so still needed to link to the .a to build

One way I did it is by extracting all the .o files from the .a and linking them into my .so. It worked fine, but it couples my .so too tightly with the .a's and it is difficult to maintain if the .a changes regularly.

Is it possible to do this in an elegant way?

Specs of the build machine -
uname -a : Linux matrix 2.4.20-28.9.XFS1.3.1smp #1 SMP Mon Jan 5 13:20:15 CST 2004 i686 i686 i386 GNU/Linux

gcc --version : gcc (GCC) 3.3.2 20040119 (Red Hat Linux 3.3.2-8)

Thanks in advance for any help
 
Old 09-25-2006, 12:14 PM   #2
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
Include the .a library as a dependency when you compile your .so lib and add it LD_ADD.

You can find an example of how to do this here:
http://distro.ibiblio.org/pub/linux/...ts/rtfm/0.6.0/

Last edited by gnashley; 09-25-2006 at 12:16 PM.
 
Old 09-28-2006, 01:24 AM   #3
delta4s
LQ Newbie
 
Registered: Aug 2005
Posts: 3

Original Poster
Rep: Reputation: 0
Thank you for your reply.
How do I use LD_ADD ? I could not find any documentation.
I could not figure it out from the given source I am a newb at this.
How can I add it to my makefile ? I am not using automake.
 
  


Reply

Tags
dynamic, linux, static



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
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 to a static library gives unresolved symbol enemorales Programming 3 01-24-2006 08:19 AM
static linking to c library lantern Programming 1 04-19-2004 08:58 AM
Static/dynamic linking ugenn Linux - Software 0 12-15-2002 11:01 PM

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

All times are GMT -5. The time now is 12:19 AM.

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