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