LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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-22-2012, 08:54 AM   #1
rupa_123
LQ Newbie
 
Registered: Mar 2012
Posts: 2

Rep: Reputation: Disabled
Is it possible to add a shared library to a static library ?


I have created a new shared library "libshared.so" . There is a existing static library "libstatic.a" . I need to refer the new code of .so into the .a files.

The libstatic.a compiles fine after I add -I<path_of_the_files_shared.so> in its Makefile.

Now this static.a is referenced in a exe . To avoid any linker issues I added -L<path_of_shared.so> -lshared in the Makefile of the exe . But when I try to compile it I get linker issue , of undefined reference to the libstatic.a for the methods of .so .

Even the nm for libstatic.a gives "U" for the methods of .so

Now my question is :

1) Is it valid to have a shared library call in a static library?
2) How to get rid of this undefined reference error ?

Please help me solve this issue.

Thanks.

Last edited by rupa_123; 03-23-2012 at 02:14 AM.
 
Old 03-23-2012, 08:22 PM   #2
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

1. You can add anything you want to a library ... including your grocery list, if you wanted.

2. You can mix'n'match shared and static references in your program: some symbols can be static, others can be dynamic.

3. By the same token, Yes: it's absolutely legal for a subroutine in a shared library to call a static reference (in which case the static reference will be included in your actual .so file). It's also legal for a subroutine in a static library to call a shared reference.
 
Old 03-24-2012, 10:25 AM   #3
rupa_123
LQ Newbie
 
Registered: Mar 2012
Posts: 2

Original Poster
Rep: Reputation: Disabled
Thanks for confirming. So can you pls elaborate on how to get rid of the linking issue when building the exe ?
 
  


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
SDL static library, shared library icecubeflower Programming 6 04-09-2009 03:10 PM
Making a static library from a given shared library vro Programming 1 07-27-2007 04:07 PM
LINUX - linking archive (static library) with shared (dynamic) library gurkama Programming 5 03-04-2007 11:11 PM
howto compile bin with my library using all-static and shared linked standart library stpg Programming 4 06-29-2004 04:20 AM


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