English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
dynamically finding libraries
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-03-15 (14:58)
From: Vu Ngoc San <san.vu-ngoc@u...>
Subject: Re: [Caml-list] dynamically finding libraries
skaller a écrit :

> Of course there is a way to do this, but probably you shouldn't.
> Modern Linices usually have package managers, so you should
> just tell the client to install the library.

I like packages, but I like as well the idea of a completely relocatable 
and distribution independent sotfware which could run, for instance, 
from a USB pen-drive.

I first tried to write a script setting LD_LIBRARY_PATH, but I have no 
idea about how to make it work with relative paths and allow symbolic links.

> Otherwise, you can write a C program that tries to call
> a function from the library, and compile, link, and run it,
> and check the result. This is a configuration time check.
> For a run time check, you can call dlopen() and dlsym()
> on the library and a known symbol in the library.
> If you do this, however, you will have to access ALL the
> symbols in the library with dlsym (that is, indirectly).

Darn. No ocaml trick for this ?

> Although Elf does allow load time lazy linkage of symbols,
> so missing symbols don't abort the program until they're
> used, there is no way I know of to have 'maybe' linkage
> of libraries. If your code is linked against a library
> the program will abort if it isn't found at run time,
> and before you get control.
> The best you can do is try to figure out the error code,
> and restart the program in a script that adds 
> the directory containing your version in LD_LIBRARY_PATH.