UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old January 27th, 2004, 07:12 AM
Micha Micha is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 18 Micha User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Difference between objects and shared objects

Hi there!

I'm a Unix/Solaris newbie and I have no idea what an (shared) object is. Can somebody eyplain it to me?

Micha

Reply With Quote
  #2  
Old January 28th, 2004, 09:46 AM
Perderabo Perderabo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 121 Perderabo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 54 sec
Reputation Power: 5
This question does not have a reasonable answer. It's like asking about the difference between a "unit" and a "central processing unit". Or asking the difference between an "expression" and a "regular expresson".

I can tell you what a "shared object" is. But it's not like there are "private objects" that together with "shared objects" are called "objects".

When you write a C program, you will typically call functions like printf(), getc(), etc. These reside in a large file called a "library". When you build the program, the compiler would arrange for linker to search a file called libc.a to find printf.

But if you have 100 different programs running, you would have 100 copies of printf in core. That is not efficient.

So you can use a shared library instead. Here one copiy of the shared library is in core. And the 100 different program can connect to it.

The shared library (on a Sun) would be called libc.so or maybe libc.so.1. The "so" stands for shared object.

Reply With Quote
  #3  
Old January 28th, 2004, 10:24 AM
Micha Micha is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 18 Micha User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I understand it so far.
But can't I do the same with a usual object?

I mean if a program can call a function from a shared object then what is the purpose of a usual object?

Micha

Reply With Quote
  #4  
Old January 28th, 2004, 12:37 PM
Perderabo Perderabo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 121 Perderabo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 54 sec
Reputation Power: 5
*sigh*

Reread the second paragraph of my first post. Now reread it once more, but substitute "usual" where I have "private". Repeat this procedure for every other adjective.

Reply With Quote
  #5  
Old January 29th, 2004, 02:09 AM
Micha Micha is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 18 Micha User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I'm so sorry, that your explaination is to big for my small brain

Look, if I compile a module in C++ I can get *.o and (for CC with -KPIC) *.so
afaik the *.o stands for object, while the *.so stands for shared object.
See what I mean? What's the difference?

Micha

Reply With Quote
  #6  
Old January 29th, 2004, 09:58 AM
Perderabo Perderabo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 121 Perderabo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 54 sec
Reputation Power: 5
Well, contrasting object files and shared objects is kinda interesting. A .o file is the real output from a compiler.

The ln command collects .o files and assembles a runable program. It can grab .o files from a directory. Or it can get them from a library. Or it can get them from a shared object.

Most other versions of unix use the term "shared library" rather than "shared object". That way you can say that a library is a collection of object files. Thanks to your question, I see where Sun got this naming convention, but I still hate it. From now on, I will use "library" to mean "library or shared object".

You don't usually run ln directly. It's common to let the compiler run it for you. That way the compiler can tell ln which libraries to search.

ln can collect .o files and create a .so library. ar can collect .o files and assemble a .a library.

Since executable files and .so libraries are created by ln which is invisibly run by the compiler, it looks like the compiler is creating them. Most compilers make .o files (and a few make .a files then invoke an assembler to create the.o) But ln or ar create libraries.

Because a library is a collection of object files, it needs some metadata, ie, a table of contents. Even if a library has only one object file, it will not be an identical copy of that object file.

I suppose that every program including the kernel that tries to use a library could be extended to work with an object file as well. This would make these programs (including the kernel) larger without providing any real new value.

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > Difference between objects and shared objects


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway