URN Logo
UNIX Resources » Linux » Linux Forum » General Linux Discussions » Page.35 » Including .so's and .a's in my program
announcement The content of this page is collected from Linux Forum, All copyrights and other associated rights are reserved by the original authors of the articles.
Resources
China Linux Forum(finished)
Linux Forum(finished)
FreeBSD China(finished)
linuxforum.com
  LinuxForum General Chat
  Linux Advocacy
  LinuxForum Polls
  Introductions
  Linux Kernel Support
  Patch Management
  Development Release
  Linux Programming
  Linux Security
  Linux Software
  Linux Hardware Problems
    Linux Video Problems
    Linux Sound Problems
  Linux Networking Support
  Linux Printing Support
  Linux Human Interface Devices Support
  Linux Data Storage Support
  Linux Applications Support
  Linux Installation Support
  Linux Laptops Support
  Linux Motherboard, Chipsets, CPU, Memory
  Miscellaneous
  Debian Linux Support
  Ubuntu Linux Support
  LiveCD Discussions
  Gentoo Linux Support
  Mandrake Linux Support
  Redhat / Fedora Linux Support
  Slackware Linux Support
  SuSE Linux Support
  CentOS Linux Support
  Linux Web Servers
  Linux DNS Servers
  Linux Database Servers
  Linux Email Servers
  Linux FTP Servers
  Linux Squid Proxy Server
  Linux Samba Help
  Linux cPanel Help
  Linux Ensim Help
  Linux Plesk Help
  Linux Webmin / Usermin Help
  Qmail Toaster Help
  Linux Games
  Windows Game Emulation
  Linux Discussions
  General Linux Discussions
  Red Hat Linux Discussions
  More Red Hat Linux Discussions
  Mandrake Linux Discussions
  Slackware Linux Discussions
  SuSE Linux Discussions
  Debian Discussions
  Samba Help
  Linux Security
  Linux Networking
  Gentoo Help
  Operating System Rant Forum
  Hardware Rants
   
Including .so's and .a's in my program
Subject: Including .so's and .a's in my program
Author: Chris Mantoulidis    Posted: 2004-02-29 13:40:50    Length: 568 byte(s)
[Original] [Print] [Top]
I read somewhere that in order to use some header files (that are
available for d/l) I must use either the .so or the .a file. It says
that .so stands for Shared Object file (I knew that) and that .a
stands for Archive file. But how am I supposed to include those files
with my code? I don't think I can link them cuz I think I can only
like object files (.o) but I may be wrong. And which one would you
suggest? .so or .a?

BTW: I'm using GCC 3.3.2 if that's of any help

Thanks in advance,
- cmad

[Original] [Print] [Top]
Subject: Including .so's and .a's in my program
Author: Larry Smith    Posted: 2004-02-29 17:21:14    Length: 2,927 byte(s)
[Original] [Print] [Top]
"Chris Mantoulidis" [cmad_x@yahoo.com] wrote in message
news:a8587dd9.0402290940.1154b761@posting.google.com...
QUOTE
I read somewhere that in order to use some header files (that are
available for d/l) I must use either the .so or the .a file. It says
that .so stands for Shared Object file (I knew that) and that .a
stands for Archive file. But how am I supposed to include those files
with my code? I don't think I can link them cuz I think I can only
like object files (.o) but I may be wrong. And which one would you
suggest? .so or .a?

BTW: I'm using GCC 3.3.2 if that's of any help

Thanks in advance,
- cmad

You can 'link' an 'so' or an 'a' just as you would
a 'o' (object file).  See the GCC docs for details.

An archive (.a) is merely a collection of '.o'
files contained within one file - the '.a' file.
The linker will extract copies of the required '.o'
files from within the '.a' file and link them into
your application (this is called 'static linking').

A Shared Object file (.so) also contains many
'.o' files within one file - the '.so' file.  The
difference is in the internal format of the '.so' file
-AND- the way the linker handles these '.o'
files at link time.  The linker inserts a REFERENCE
into you compiled program for each '.o' file found
in '.so' files.  At runtime (when you execute
your program) the system RESOLVES all
of the REFERENCES in your program by
finding the '.so' files on disk and loading the
appropriate '.o' files from within them as part
of your program.

The choice between using 'libsomething.so' and
'libsomething.a' depends on several factors.

- linking with '.so' files produces smaller programs.
  IF you plan to distribute your program to other
  machines -and- you are sure that the other machines
  have, or can get, the '.so' files you used at link-time,
  then this is the way to go.  Most of Linux is done this
  way - as the core libs are in '.so' format and are
  available on all machines.
- linking with '.a' files produces bigger programs, but
  your program is 'self contained' and you do not
  have to concern yourself with the availability of any
  '.so' files when you run your program on another
  machine.  This approach is usually used when your
  program requires some libs that are either custom
  or hard to find.

Regards,
Larry

[Original] [Print] [Top]
Subject: Including .so's and .a's in my program
Author: Chris Mantoulidis    Posted: 2004-03-01 01:28:27    Length: 2,615 byte(s)
[Original] [Print] [Top]
QUOTE
You can 'link' an 'so' or an 'a' just as you would
a 'o' (object file).  See the GCC docs for details.

An archive (.a) is merely a collection of '.o'
files contained within one file - the '.a' file.
The linker will extract copies of the required '.o'
files from within the '.a' file and link them into
your application (this is called 'static linking').

A Shared Object file (.so) also contains many
'.o' files within one file - the '.so' file.  The
difference is in the internal format of the '.so' file
-AND- the way the linker handles these '.o'
files at link time.  The linker inserts a REFERENCE
into you compiled program for each '.o' file found
in '.so' files.  At runtime (when you execute
your program) the system RESOLVES all
of the REFERENCES in your program by
finding the '.so' files on disk and loading the
appropriate '.o' files from within them as part
of your program.

So .so for Linux is _probably_ what a .dll is for Windows. Thanks :)
 
QUOTE
The choice between using 'libsomething.so' and
'libsomething.a' depends on several factors.

- linking with '.so' files produces smaller programs.
IF you plan to distribute your program to other
machines -and- you are sure that the other machines
have, or can get, the '.so' files you used at link-time,
then this is the way to go.  Most of Linux is done this
way - as the core libs are in '.so' format and are
available on all machines.
- linking with '.a' files produces bigger programs, but
your program is 'self contained' and you do not
have to concern yourself with the availability of any
'.so' files when you run your program on another
machine.  This approach is usually used when your
program requires some libs that are either custom
or hard to find.

The .so is made by files I d/led from the inet and are not in every
computer. So I guess I must go with the .a files.

Thanks for the long explanation, it was really helpful :)

- cmad

[Original] [Print] [Top]
Subject: Including .so's and .a's in my program
Author: Larry Smith    Posted: 2004-03-01 03:07:16    Length: 3,336 byte(s)
[Original] [Print] [Top]
"Chris Mantoulidis" [cmad_x@yahoo.com] wrote in message
news:a8587dd9.0402292128.6d4fc3bc@posting.google.com...
QUOTE
You can 'link' an 'so' or an 'a' just as you would
a 'o' (object file).  See the GCC docs for details.

An archive (.a) is merely a collection of '.o'
files contained within one file - the '.a' file.
The linker will extract copies of the required '.o'
files from within the '.a' file and link them into
your application (this is called 'static linking').

A Shared Object file (.so) also contains many
'.o' files within one file - the '.so' file.  The
difference is in the internal format of the '.so' file
-AND- the way the linker handles these '.o'
files at link time.  The linker inserts a REFERENCE
into you compiled program for each '.o' file found
in '.so' files.  At runtime (when you execute
your program) the system RESOLVES all
of the REFERENCES in your program by
finding the '.so' files on disk and loading the
appropriate '.o' files from within them as part
of your program.

So .so for Linux is _probably_ what a .dll is for Windows. Thanks :)


Yes, exactly, '.dll' and '.so' are both Dynamic Link libs.

QUOTE
The choice between using 'libsomething.so' and
'libsomething.a' depends on several factors.

- linking with '.so' files produces smaller programs.
IF you plan to distribute your program to other
machines -and- you are sure that the other machines
have, or can get, the '.so' files you used at link-time,
then this is the way to go.  Most of Linux is done this
way - as the core libs are in '.so' format and are
available on all machines.
- linking with '.a' files produces bigger programs, but
your program is 'self contained' and you do not
have to concern yourself with the availability of any
'.so' files when you run your program on another
machine.  This approach is usually used when your
program requires some libs that are either custom
or hard to find.

The .so is made by files I d/led from the inet and are not in every
computer. So I guess I must go with the .a files.


OR the documentation for your program can specify
that certain libs (.so) are required to run your program.
You'll see a note on '.so' prerequisites  in the docs for
many programs - that's a pretty typical approach.
The user then knows to obtain those libs before
using your program.

QUOTE
Thanks for the long explanation, it was really helpful :)

- cmad


[Original] [Print] [Top]
« Previous thread
Is Linux POSIX compliant?
General Linux Discussions
Page. 35
Next thread »
terminal type unknown
     

Copyright © 2007 UNIX Resources Network, All Rights Reserved.      About URN | Privacy & Legal | Help | Contact us
Powered by FreeBSD    webmaster: webmaster@unixresources.net
This page created on 2007-08-01 12:17:17, cost 0.026425123214722 ms.