Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Can I include libraries in archives.

Posted on 2001-08-03
5
Medium Priority
?
196 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 300 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

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

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

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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 learn how to count occurrences of each item in an array.

610 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