Solved

Can I include libraries in archives.

Posted on 2001-08-03
5
191 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

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…
Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

732 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