Penguin
Diff: SharedLibraries
EditPageHistoryDiffInfoLikePages

Differences between current version and predecessor to the previous major change of SharedLibraries.

Other diffs: Previous Revision, Previous Author, or view the Annotated Edit History

Newer page: version 7 Last edited on Friday, February 20, 2004 12:51:55 pm by AristotlePagaltzis
Older page: version 6 Last edited on Thursday, February 19, 2004 2:21:19 pm by JohnMcPherson Revert
@@ -1,65 +1 @@
-Shared libraries are immutable blocks of code which can potentially be shared between many concurrent processes.  
-  
-This has many advantages:  
-* You can upgrade the shared library without having to upgrade all the programs that depend on it. For instance, upgrading to a newer version of glibc that can use the new Frobitz extension on your processor for faster memcpy(3)'s will give all programs that use glibc the faster code without having to recompile every program on your machine.  
-* It saves considerably on memory footprint, especially when you have many porcesses with little state but much code. This is because most of the shared library can be loaded into memory only once and then all the programs can use it. SharedLibraries mean that the column in ps(1) never add up.  
-  
-On many Unix systems, you can use the ldd(1) command to see which shared libraries a program is linked against:  
- $ ldd /sbin/mke2fs  
- libext2fs.so.2 => /lib/libext2fs.so.2 (0x40023000)  
- libcom_err.so.2 => /lib/libcom_err.so.2 (0x40037000)  
- libe2p.so.2 => /lib/libe2p.so.2 (0x40039000)  
- libuuid.so.1 => /lib/libuuid.so.1 (0x4003e000)  
- libc.so.6 => /lib/libc.so.6 (0x40041000)  
- /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)  
-  
-Trying this on a staticly linked program:  
- $ ldd /sbin/init  
- not a dynamic executable  
-  
-  
-On [Darwin ], the corresponding program is called otool:  
- $ otool -L /bin/zsh  
- /bin/zsh:  
- /usr/lib/libncurses.5.dylib (compatibility version 5.., current version 5..)  
- /usr/lib/libSystem.B.dylib (compatibility version 1.., current version 60..)  
-  
-----  
-!Creating Shared Libraries  
-Drepper wrote a nice document about how to write shared libraries http://people.redhat.com/drepper/dsohowto.pdf  
-  
-----  
-To create a shared library using gcc/ld:  
-  
-I used the following snippet in my Makefile  
-  
- LIBRT=librtclient.so  
- LIBRTM=librtclient.so.1  
- LIBRTV=librtclient.so.1..1  
- LDFLAGS=-L/usr/local/wand/lib/  
-  
- $(LIBRT): rtclient.o fifo.o utils.o  
- gcc -shared -Wl,-soname,$(LIBRT) -o $(LIBRTF) $^ $(LDFLAGS) -lzl  
-  
-This creates a shared library called librtclient.so.1..1, with the shared object name (soname) of librtclient.so. It also specifies libzl as a dependancy of this library. libzl already resides in /usr/local/wand/lib (its a modified version of libz, I placed both shared and static versions of it in /usr/local/wand/lib manually)  
-  
-I moved librtclient.so.1..1 to /usr/local/wand/lib/  
-  
-I added /usr/local/wand/lib to /etc/ld.so.conf and ran ldconfig. This complained about being unable to symlink to /usr/local/wand/lib/librtclient.so.1..1,  
-so i manually added the required symlinks and reran ldconfig:  
-  
- cd /usr/local/wand/lib  
- ln -sf librtclient.so.1..1 librtclient.so  
- ln -sf librtclient.so.1..1 librtclient.so.1  
- ldconfig  
-  
-  
-Now, when I build a program that uses librtclient, I can simply set my LDLIBS flag as follows:  
-  
- LDLIBS += -L/usr/local/wand/lib/ -lrtclient  
-  
-And all my programs use the shared library in that directory, when I change the library the next time the programs are run they get the new version!  
-  
-Of course, if I change the API, I need to update the minor version number, and recompile my programs against the new version . Likewise, if I make a non-backwards compatable upgrade, I should upgrade the major version number on the library, and again recompile my programs (probably checking to see they still work ok!)  
-  
---DanielLawson  
+Describe [ SharedLibraries] here