Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 02-16-2006, 01:47 PM   #1
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:


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

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

Old 02-16-2006, 03:30 PM   #3
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.


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

All times are GMT -5. The time now is 06:43 AM.

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