Orbit - Package Manager - Specification/ideas

Johannes Pfau spam at example.com
Tue Jul 19 01:16:10 PDT 2011


Jacob Carlborg wrote:
>On 2011-07-18 18:03, Johannes Pfau wrote:
>> It would be possible to install libraries into the dmd default search
>> path. Right now, this would be /usr/include/d/dmd and library files
>> in /usr/lib on posix, but any path can be used as long as it's
>> included in dmd.conf. However, this means that only one version of a
>> library can be installed system-wide, so it's not optimal.
>>
>> It should also be noted, that linking against a specific library
>> version can only work well with static libraries. With static
>> libraries you can give linker a specific path to the library at
>> compile time (So you can have multiple versions in different
>> directories). Using different directories with dynamic libraries
>> requires setting LD_LIBRARY_PATH before executing a program, so this
>> won't work. We'll have to use the library versioning mechanism
>> that's used by C libraries (e.g for linux:
>> http://www.ibm.com/developerworks/linux/library/l-shlibs/index.html
>> ). I don't know if windows even supports library versioning, but as
>> windows programs usually don't install dlls globally that's less of a
>> problem.
>
>You can give a specific path to the compiler with dynamic libraries as 
>well. Link with libfoo, version 3.4.0:
>
>dmd -L-L/path/to/libfoo-3.4.0 -L-lfoo
>
>Or have I missed something?
>

I'd have to test that, but I doubt it will work. This will help to find
the library at compile time, but not at runtime. The runtime linker
will only search in directories listed in /etc/ld.so.conf.d or in the
LD_LIBRARY_PATH variable. Each .so library has a 'soname' embedded. If
you link like in your example command the resulting binary only
contains the sonames of the libraries it needs, not the full path. At
runtime, the linker then reads that soname and searches in its cache for
a library with the same soname. It might be possible to make this
soname mechanism use absolute paths or subdirectories, but this seems
like a hack. Sonames are usually just "libfoo.so.3" where 3 is a ABI
revision. I think we'll eventually have to install shared libraries
exactly the way C does it, i.e all in /usr/lib and using the soname
versioning. But we can think about that when dmd finally supports
shared libraries on linux, it's not important right now.

-- 
Johannes Pfau



More information about the Digitalmars-d mailing list