LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-12-2006, 12:11 AM   #1
g4j31a5
Member
 
Registered: Sep 2006
Distribution: open SuSE 10.0
Posts: 116

Rep: Reputation: 15
About libraries.


Hi, I just wanted to ask questions about library. What's the difference of .so, .la, .a ? How do I know what a binary is linked against? Thanks.
 
Old 12-12-2006, 12:33 AM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

.a files are "static libraries. You create them with "ar"; the binary code from these files is linked directly into your executable.

.so files are "shared libraries". You create them with "ld"; the executable merely contains a reference to the binary objects in the shared library. The library code itse;f isn't loaded until runtime, making the executable both smaller, and more flexible.

Both .a and .so libraries are very common: they're both used in just about every executable you'll build.

.la files, on the other hand, with the Gnu "libtool" package. They are somewhat less commonly used. You can read more about "libtool" - and the differences between .a, .so and .la files - here:

http://developer.gnome.org/doc/books...libraries.html

'Hope that helps .. PSM
 
Old 12-14-2006, 08:56 PM   #3
g4j31a5
Member
 
Registered: Sep 2006
Distribution: open SuSE 10.0
Posts: 116

Original Poster
Rep: Reputation: 15
Thanks, btw how do I know what library a binary is linked against? I tried to develop with SDL, but I didn't know if it was the libSDL.a or libSDL.so that was linked to my binary. I made it from KDevelop's wizard.
 
Old 12-14-2006, 09:16 PM   #4
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
You can use the ldd command to list the dynamic libraries a program uses:
Code:
 ldd tar
        librt.so.1 => /lib64/librt.so.1 (0x00002b1d59c18000)
        libc.so.6 => /lib64/libc.so.6 (0x00002b1d59d21000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00002b1d59f51000)
        /lib64/ld-linux-x86-64.so.2 (0x00002b1d59afb000)
Of course, since you have the source code, you can read it as well.
 
Old 12-15-2006, 12:50 AM   #5
g4j31a5
Member
 
Registered: Sep 2006
Distribution: open SuSE 10.0
Posts: 116

Original Poster
Rep: Reputation: 15
Thanks. Yeah, maybe I can actually read it from the source code. But I don't know how. Still not familiar with Linux.
 
  


Reply



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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Where can I get all the libraries I need? Lord Hakk Linux - Software 4 04-02-2006 09:08 AM
libraries in c c++ mannahazarika Programming 4 01-07-2006 02:09 AM
c libraries kpachopoulos Programming 1 10-19-2005 05:37 PM
using C-Libraries from C++ Yoko Programming 2 10-02-2005 04:50 PM
libraries sharapchi Slackware 2 03-10-2005 05:40 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:36 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration