LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch
User Name
Password
Linux From Scratch This Forum is for the discussion of LFS.
LFS is a project that provides you with the steps necessary to build your own custom Linux system.

Notices


Reply
  Search this Thread
Old 02-14-2019, 03:25 AM   #1
parotta36
Member
 
Registered: Dec 2017
Location: Madurai
Distribution: Linux Mint | Slackware
Posts: 59

Rep: Reputation: Disabled
Shared libraries


I was reading 6.1 Introduction, and was linked to BLFS ch 2 "Libraries: Static or shared?". In it,

Quote:
Within the book, there are various places where configure switches such as --disable-static are employed, and other places where the possibility of using system versions of libraries instead of the versions included within another package is discussed. The main reason for this is to simplify updates of libraries.
Does this mean that when --disable-static is used, the corresponding package uses the libraries from other packages?

What are system versions of libraries?
Are they installed when the OS is installed, the libs for the OS to run properly?

Where are the lib versions from other packages installed?
Will there not be a conflict if these packages and system packages are same libs with only differents versions?

Are shared libraries, used to minimize memory and simplify update of libraries?

Last edited by parotta36; 02-15-2019 at 12:33 AM.
 
Old 02-14-2019, 03:41 PM   #2
RandomTroll
Senior Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 1,204

Rep: Reputation: 200Reputation: 200Reputation: 200
Programs use libraries either dynamically or statically. When a program uses a dynamic library, the OS loads it into memory and tells the program where to access it. When a program uses a library statically the routine the program calls gets built into the program at compilation. Thus a program built with static libraries is usually much larger on disk, and in RAM when running. A dynamic library only has to be loaded once: all programs that call it use the same instance. One may want to build a program statically if it may be used when the dynamic libraries aren't available, as may happen when there's a problem with a disk.
 
1 members found this post helpful.
Old 02-15-2019, 12:34 AM   #3
parotta36
Member
 
Registered: Dec 2017
Location: Madurai
Distribution: Linux Mint | Slackware
Posts: 59

Original Poster
Rep: Reputation: Disabled
Here, do they mean that when --disable-static is used, the corresponding package uses the libraries from other packages?
 
Old 02-15-2019, 12:42 AM   #4
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 12,606

Rep: Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939
disable static is a link time option, it means the given app should use dynamic libraries (.so files) instead of their static counterparts.
But it is a link time option, you specify it during the build of the application.
When you run that app it will look for these .so files (libraries) and will try to use them (if found). The app does not really care about the question "where are these libraries coming from". So yes, probably they are part of other packages, or whatever. It depends on the maintainer of that host.
 
1 members found this post helpful.
Old 02-15-2019, 12:58 PM   #5
parotta36
Member
 
Registered: Dec 2017
Location: Madurai
Distribution: Linux Mint | Slackware
Posts: 59

Original Poster
Rep: Reputation: Disabled
So, the libraries that were installed for the OS(system libraries) and libraries of other packages are all heaped up in one dir(/lib) and it's subdirectories, for use?
 
Old 02-15-2019, 01:09 PM   #6
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 12,606

Rep: Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939
this is more or less true (but a bit simplified). Libraries - in general - are used by apps and they are stored in /lib (or a similar dir) to be able to use them. Not for the OS, for any app which needs.
You can imagine, a library contains some features, if an app wanted to use those features need to use that lib (that's why they are shared).
wiki shared libraries
 
1 members found this post helpful.
Old 02-15-2019, 01:56 PM   #7
hazel
Senior Member
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 2,898
Blog Entries: 7

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Since you are talking about LFS, some of the answers given here are not entirely relevant.

The term "system libraries" usually means libraries that are already on the system, which a new package can link to. Some packages (notably Firefox) come with their own versions of these libraries, allowing unprivileged users to install them under their own directories and have everything they need to run the program guaranteed to be at hand whether the libraries are on the system or not. But this is not the normal way that Linux does things.

System libraries are installed from separate packages. Each commonly-used library comes in a package of its own; once it is installed, any program that needs it can link to it. In binary distros you can study this by using a graphical package manager like Debian's synaptic. You can see that there are library packages and application packages.

A complicating factor in LFS is that everything is built locally. This means that packages which have their own internal versions of certain libraries have to be told during the build whether to use these versions or the system versions. Usually the latter is preferable, as built-in libraries are often poorly maintained and contain security flaws. But sometimes the build can't use any version of a particular library other than the one it came with. Firefox is increasingly incompatible with external libraries. There was some recent correspondence about this on the lfs-dev mailing list.

See: https://www.linuxquestions.org/quest...ed-them-37743/

Last edited by hazel; 02-15-2019 at 01:59 PM. Reason: link added
 
1 members found this post helpful.
Old 02-16-2019, 12:54 PM   #8
RandomTroll
Senior Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 1,204

Rep: Reputation: 200Reputation: 200Reputation: 200
A dynamically-linked program looks in the libraries pointed to by /etc/ld.so.cache. ld.so.cache points to all the libraries in the directories in /etc/ld.so.conf after ldconfig runs. Slackware's start-up includes running ldconfig. If I build a new library, after I install it, I have to run ldconfig for a program to use it. If I create a new directory of libraries I have to add it to ld.co.conf. Build a program with static linking, then build it with dynamic linking, compare the size.

If it's a diagnostic or repair program you want to work even if a problem causes dynamic libraries to be unavailable you want it statically linked.
 
1 members found this post helpful.
Old 02-16-2019, 12:59 PM   #9
hazel
Senior Member
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 2,898
Blog Entries: 7

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Most makefiles for building libraries include the ldconfig command as part of the install target, so you don't necessarily need to run it yourself. But it does need to be run somehow.
 
1 members found this post helpful.
  


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
Static libraries vs shared Libraries catallergy Linux - Newbie 2 03-16-2010 01:30 PM
Urgent !!! rpm: error while loading shared libraries: libelf.so.1: cannot open shared tinaa Linux - Software 5 12-02-2008 03:19 PM
error while loading shared libraries: libdb-4.1.so: cannot open shared object file putquery8581 Linux - Software 1 10-01-2004 07:03 AM
mplayer: error while loading shared libraries: libdvdread.so.3: cannot open shared ob Bruce Hill Slackware 6 12-11-2003 08:34 AM
linux init error in loading shared shared libraries akaran Linux - Software 1 05-28-2003 04:40 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch

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

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