[08:09] <excalibr> gasp..
[08:28] <excalibr> hyperair: you there?
[08:29] <hyperair> no
[08:35] <excalibr> any idea why most *.so in /usr/lib have symlinks point back to those *.so?
[08:36] <angch> excalibr: ? just pointing to the latest version.
[08:38] <excalibr> but why the need for symlinks..
[08:38] <hyperair> excalibr: library versioning.
[08:38] <angch> so you get the latest dot version/..?
[08:39] <hyperair> libraries typically read the SONAME from within the librar (objdump -p $lib) and add them to the REQUIRED list
[08:39] <hyperair> or was it NEEDED
[08:39] <hyperair> i think
[08:39] <hyperair> er
[08:39] <hyperair> sorry
[08:40] <hyperair> compilers read the SONAME from within the library, and add NEEDED entries into the ELF header of the output file
[08:40] <hyperair> the SONAME typically looks like  libfoo.so.1
[08:40] <hyperair> .1 indicates that this is ABI version 1
[08:40] <hyperair> when this number changes, ABI is broken
[08:40] <hyperair> when ABI is broken, your program will crash
[08:41] <hyperair> so you'll need to recompile it
[08:41] <hyperair> hence, libraries are typically stored in one of the LD_LIBRARY_PATHs as libfoo.so.1
[08:41] <hyperair> and libfoo.so.2 can be co-installed with libfoo.so.1
[08:42] <hyperair> so you can have legacy apps that still require libfoo.so.1 installed alongside new apps that use libfoo.so.2
[08:42] <hyperair> when you compile, you typically do something like gcc -lfoo ...
[08:42] <hyperair> "foo" gets translated by gcc into libfoo.so
[08:43] <hyperair> and so libfoo.so will point to the appropriate library
[08:43] <hyperair> appropriate library version, i mean
[08:43] <excalibr> so when you build and install a custom library, which file should you point to ldconfig to update your lib cache? the symlink or its real .so ? or either is fine?
[08:43] <hyperair> you don't
[08:44] <hyperair> you just dump your library into one of the ld paths, and then run ldconfig
[08:44] <hyperair> that's all ther eis
[08:44] <hyperair> in ubuntu we have libfoo.so inside the -dev package
[08:44] <hyperair> as in the symlink
[08:44] <hyperair> because you only need that when compiling
[08:45] <hyperair> libfoo.so.1 is inside the libfoo1 package
[08:45] <hyperair> which will be depended upon by packages that are compiled against it
[08:59] <excalibr> that's some lengthy explaination :P ok if i understand you correctly, soname inside the library file is what define the lib version, not the number after .so. on its filename?
[09:20] <excalibr> or not?
[09:22] <angch> excalibr: i think you don't fully grok it.
[09:23] <angch> run a program , program needs foo.so.0. it is symlinked to foo.so.0.1 which is the actual one installed. latest for now. when upgraded to foo.so.0.2, it still points to foo.so.0 but it is now symlinked to foo.so.0.2
[09:24] <angch> programs refer to symlink to find the latest version (with same ABI (?).
[09:24] <angch> so you don't have to muck with programs to use the latest version.
[09:24] <angch> just dereference the symlink.
[09:35] <excalibr> angch: i understand that part what i dont understand is..
[09:38] <excalibr> i built a lib with soname libfoo.so.0 during compile and named the output file as libfoo.so.4.2 - when i ran ldconfig i notice it created a symlink named corresponding to the soname, libfoo.so.0 which points to libfoo.so.4.2
[09:40] <excalibr> so that means program that needs libfoo.so.0 can still find the lib right?
[09:40] <excalibr> but actually it can't
[09:41] <angch> *shrug* no idea, sorry, not gonna just simple stab at an answer.
[09:41] <excalibr> or do i totally misunderstood hyperair and your explaination?
[09:42] <angch> i totally don't get your question. :-/ sorry.
[09:43] <excalibr> alamak
[09:44] <hyperair> angch: no, you've got it wrong.
[09:44] <hyperair> wait
[09:44] <hyperair> sorry, read wrongly
[09:44] <hyperair> that's pertty much so
[09:45] <hyperair> excalibr: basically when you compile your program against libfoo.so, you'll do something like gcc foo.c -lfoo
[09:45] <hyperair> excalibr: this makes gcc look into /usr/lib/libfoo.so
[09:45] <hyperair> or these days, /usr/lib/x86_64-linux-gnu/libfoo.so
[09:45] <excalibr> :D
[09:45] <hyperair> libfoo.so is a symlink to libfoo.so.0
[09:46] <hyperair> the linker reads the SONAME field out of libfoo.so.0
[09:46] <hyperair> which you can get by objdump -p /usr/lib/libfoo.so.0 | grep SONAME
[09:46] <hyperair> objdump -p /usr/lib/libkate.so.1| grep SONAME                                                                                                                           [ 5:46PM] SONAME               libkate.so.1
[09:47] <hyperair> % objdump -p /usr/lib/libkate.so.1| grep SONAME SONAME               libkate.so.1
[09:47] <hyperair> bah
[09:47] <hyperair> whatever
[09:47] <hyperair> after the first SONAME there's a newline there
[09:47] <angch> hyperair: dunno. ldd /bin/ls should give a better picture to explain things, imho.
[09:47] <hyperair> angch: no, i want to show the SONAME.
[09:47] <angch> ok
[09:47] <hyperair> as in i'm explaining the anatomy of a library
[09:48] <excalibr> hyperair: then when you run the program, does it look for libfoo.so or libfoo.so.0?
[09:48] <angch> i'm lost as to the question in the first place...
[09:48] <hyperair> excalibr: so anyway, after whatever's in the SONAME gets added to your application under NEEDED
[09:48] <hyperair> which you can see when you do ldd /bin/ls
[09:48] <hyperair> or objdump -p
[09:48] <hyperair> excalibr: try out the commands i gave you
[09:48] <hyperair>  objdump -p /bin/ls | grep NEEDED
[09:48] <hyperair>   NEEDED               libselinux.so.1
[09:48] <hyperair>   NEEDED               librt.so.1
[09:48] <hyperair>   NEEDED               libacl.so.1
[09:48] <hyperair>   NEEDED               libc.so.6
[09:49] <hyperair> when you run the program, the linker looks for everything that's listed there
[09:50] <hyperair> excalibr: as for your ldconfig question..
[09:50] <hyperair> that's because it's not the file name that matters, it's the SONAME.
[09:50] <hyperair> you must get your SONAME correct
[10:00] <excalibr> hyperair: does that mean if the version in lib's soname and one on its filename doesn't match each other, a program that uses the lib could still find the lib and run fine as long as the lib's soname is correct?
[10:00] <hyperair> no
[10:01] <excalibr> just now you said filename name doesnt matter?
[10:01] <hyperair> "libfoo.so.0" is copied from the SONAME of the library, into a NEEDED entry of your output binary.
[10:01] <hyperair> when you run your binary, the dynamic loader looks for libfoo.so.0 inside your LD_LIBRARY_PATH
[10:02] <hyperair> however, if you get your SONAME wrong, e.g..
[10:02] <hyperair> you have /usr/lib/libfoo.so.0, with a SONAME of libbar.so.0
[10:02] <hyperair> then your output binary will have a NEEDED entry saying libbar.so.0
[10:03] <hyperair> so your dynamic loader will look for libbar.so.0 instead of libfoo.so.0
[10:03] <hyperair> and since the file doesn't exist, it'll fail
[10:06] <excalibr> it'll still fail even if you make a symlink named libbar.so.0 pointing to libfoo.so.0?
[10:08] <hyperair> oh then it'll work.
[10:08] <hyperair> you have to understand that the loader isn't very smart
[10:08] <hyperair> it's simple
[10:08] <hyperair> it just looks for /usr/lib/$SONAME
[10:09] <hyperair> and the linker just encodes the SONAME from the library into a NEEDED entry of the binary
[10:15] <hyperair> excalibr: http://paste.debian.net/241167/ <-- see this
[13:21] <excalibr> hyperair: about that code paste, i got what you're trying to say
[13:21] <hyperair> good
[13:21] <hyperair> then it served its purpose :)
[13:26] <excalibr> yea thanks so much :)
[13:27] <hyperair> no problem :)