![A stick figure smiling](/images/welcome.jpg)
Here's a preview from my zine, Bite Size Linux!! If you want to see more comics like this, sign up for my saturday comics newsletter or browse more comics!
![Image of a comic. To read the full HTML alt text, click "read the transcript".](/images/uploads/shared-libraries.png)
read the transcript!
panel 1:
Most programs on Linux use a bunch of C libraries.
Some popular libraries:
openssl (for SSL!)
sqlite (embedded db?)
zlib (gzip!)
lib pcre (regular expressions!)
libstdc++ (C++ standard library!)
panel 2:
There are 2 ways. to use any library:
1. Link it into your binary
your code (big binary with lots of things!) | zlib | sqlite
and
2. Use separate shared libraries
your code
zlib
sqlite
(all different files)
panel 3:
Programs like this
your code | zlib | sqlite
are called “statically linked”
programs like this
your code
zlib
sqlite
are called “dynamically linked”
panel 4:
person 1: how can I tell what shared libraries a Program is using?
person 2: Idd!!
libz.so.1 => /lib/x86-64...
lib resolv.so.2 =>....
libc.so.6 =>...
+34 more
panel 5:
person 1: I got a “library not found” error when running my binary?!
person 2: If you know where the library is, try setting the LD_LIBRARY_PATH
environment variable
dynamic linker: LO-LIBRARY_PATH
tells me where to look!
panel 6: Where the dynamic linker looks
ODT. RPATH
in your executableLD- LIBRARY_PATH
DT- RUNPATH
in executable/etc/ld.so.cache.
(runIdconfig -p
to See contents)/lib, /usr/lib
Saturday Morning Comics!
Want another comic like this in your email every Saturday? Sign up here!