Solved

Can I include libraries in archives.

Posted on 2001-08-03
5
187 Views
Last Modified: 2013-11-18
Hi,
Is it possible to include shared libaries in archives with "ar" command".
For example if i have file1.o and lib1.so, can I make an archive including both of them?

Thanks,
Sasi,
0
Comment
Question by:ksn76
  • 3
  • 2
5 Comments
 
LVL 5

Expert Comment

by:bryanh
ID: 6352192
I think the question is, is it possible _not_ to?  I do this with 'ar r file1.o lib1.so'.

If the shared library is stripped (has no symbol table), then you've got a problem.  Then you need something that reconstructs a symbol table from the dynamic symbol section in lib1.so.  I don't know of anything that does that, but it should be feasible.
0
 
LVL 2

Expert Comment

by:dhymes
ID: 6354005
ar, the standard Unix archiver, is routinely used to create Unix object libraries. The resulting file, which ends in ".a", can therefore be referred to as an archive; however, the term library is recommended as it is more descriptive for our purposes. Archive files created by ar can contain any type of file, including text and executable files; in contrast, object libraries contain only compiled object files.

The syntax for building a library from a group of object files is

ar r


for example,

ar r libmultidim.a hypercube.o mobius_strip.o klien_bottle.o tesseract.o

will create a library in the current directory called libmultidim.a, which contains the four object files given in the example.

So, if you are asking "Can I add an .SO file to an object library and expect the linker "ln" to pick up the objects at linktime/runtime the answer is NO.

If you are asking "Can I add an .SO file to an archive file?" The answer is you can add any file to an archive file.
0
 
LVL 2

Accepted Solution

by:
dhymes earned 100 total points
ID: 6354007
ar, the standard Unix archiver, is routinely used to create Unix object libraries. The resulting file,
which ends in ".a", can therefore be referred to as an archive; however, the term library is recommended
as it is more descriptive for our purposes. Archive files created by ar can contain any type of file,
including text and executable files; in contrast, object libraries contain only compiled object files.


The syntax for building a library from a group of object files is

ar r


for example,

ar r libmultidim.a hypercube.o mobius_strip.o klien_bottle.o tesseract.o

will create a library in the current directory called libmultidim.a, which contains the four object
files given in the example.

So, if you are asking "Can I add an .SO file to an object library and expect the linker "ln" to pick
up the objects at linktime/runtime the answer is NO.

If you are asking "Can I add an .SO file to an archive file?" The answer is you can add any file to
an archive file.
0
 
LVL 5

Expert Comment

by:bryanh
ID: 6356152
>So, if you are asking "Can I add an .SO file to an object library and expect the linker "ln" to pick
>up the objects at linktime/runtime the answer is NO.

Well, it works for me.

As .so files are ELF object files, just as .o files are, 'ln' can pick up the objects the same.
0
 
LVL 2

Expert Comment

by:dhymes
ID: 6358334
I pulled the above out of the linux man pages, you may know something they don't, or it is possible that some linkers can handle shared files within an archive file. The linker I am using cannot.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
video playback resume on webpages 2 73
monitor and log every file access on redhat/linux 4 124
jQuery or Javascript animation question 6 69
Select distinct 25 103
Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question