LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-16-2006, 02:47 PM   #1
merchtemeagle
Member
 
Registered: Oct 2004
Location: Belgium
Distribution: Slackware 13.37
Posts: 512

Rep: Reputation: 31
Static vs shared


When you ./configure an application to compile it, in most cases you can choose as options:

--enable-static
--enable-shared

What are the advantages/disadvantages of both options?
 
Old 02-16-2006, 02:55 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Mainly size & "portability" ... have a search on the forums, I
gave a spiel on that not too long ago ;)


Cheers,
Tink
 
Old 02-16-2006, 04:30 PM   #3
atom
Member
 
Registered: Feb 2004
Location: Slovenia
Distribution: archlinux
Posts: 271

Rep: Reputation: 31
Static linking of libraries is faster (on startup), and ensures that the application will work even if you don't have the library installed. However, such applications do not share the same instance of the library in memory, and therefore waste precious RAM.

If you share libraries, one library is only loaded into RAM once (therefore giving you a performance boost if you have it loaded already by another program or another instance of the same program), and the library can be upgraded for a binary-compatible version at any time, without the program having to be recompiled, allowing for fixing bugs faster and easier.

The performance penality for loading shared libraries is almost negated by the use of the program called prelink (called prelinking a library), if you're interested, read up on prelink on gentoo howtos, they are a useful theoretical guide for other distros as well, even if they don't use portage...

So, to sum up, a statically-linked program will run anywhere and not suffer from the danger of missing libraries, but will be less efficient and waste RAM.

Conclusion: if you have a system for your own leasure, use dinamic linking (with optional prelink), if you are a developer that uses an obscure and weird library, or are a programmer that isn't sure that QT is installed on a target system, use static linking.



And cheers.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
shared to static library ofada Programming 2 07-08-2009 12:54 PM
LAN with static IP addresses and shared internet connection #2 Klas Linux - Networking 10 01-26-2004 11:43 AM
compiling with shared and static libraries jinksys Programming 1 11-22-2003 05:54 AM
Qt Libs Static or Shared magicm Slackware 2 10-15-2003 06:05 AM
gaim trying to link static and shared libraries rose_bud4201 Linux - Software 0 09-28-2003 01:27 AM


All times are GMT -5. The time now is 06:28 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration