LinuxQuestions.org
Register a domain and help support LQ
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-19-2010, 04:07 AM   #1
abhijitd
LQ Newbie
 
Registered: Jul 2008
Posts: 3

Rep: Reputation: 0
Question Program includes .so which includes .a


Hello,

I am a novice Linux user. I have a question.

I have prepared a static lib(.a) comprising 2 function definitions. I have created a different shared library(.so) comprising 2 more functions. The two functions of .so use the functions defined in the .a file. That is, the .so file uses the services of the .a file.

Next, I create an executable that uses the shared library(.so). When I build my executable, it needs to be linked with the .a file as well. Otherwise it gives me undefined reference for the functions defined in the .a file. Why is that so? I am posing this question because, the .a file has already been included(static linking) while bulding the .so.

Is there any workaround so that I need not link the .a file with my final executable?

Thank you,
AD
 
Old 03-19-2010, 05:56 AM   #2
irmin
Member
 
Registered: Jan 2010
Location: the universe
Distribution: Slackware (modified), Slackware64 (modified), openSuSE (modified)
Posts: 342

Rep: Reputation: 62
What are the commands you use to create the static library and the shared library?

If the static library has been specified when creating the shared library, then there is no need to include the static library in your main program, except when you use the static library directly.
 
1 members found this post helpful.
Old 03-19-2010, 08:34 AM   #3
abhijitd
LQ Newbie
 
Registered: Jul 2008
Posts: 3

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by irmin View Post
What are the commands you use to create the static library and the shared library?

If the static library has been specified when creating the shared library, then there is no need to include the static library in your main program, except when you use the static library directly.
Well Thanks for your input. I found out that the order of the lib matters. Again it is good to add start_group and end_group for the archives in order to resolve the cyclic dependency.

Thank you,
AD
 
  


Reply

Tags
reference, undefined


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
HELP:Error running program which includes system call stefio Programming 2 07-27-2008 10:37 AM
X includes? fredws Mandriva 3 04-11-2005 09:27 PM
where can i download a good manufacturing program that includes MRP and Prod planning shamz Linux - Software 0 08-05-2004 02:27 PM
X-includes Dutch_Can Linux - Newbie 4 05-14-2004 12:29 PM
X includes ddpicard Programming 1 10-26-2001 01:35 AM


All times are GMT -5. The time now is 12:26 PM.

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 Google+: linuxquestions
Open Source Consulting | Domain Registration