From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 0E410BC0A for ; Thu, 15 Mar 2007 15:58:38 +0100 (CET) Received: from amazone1.ujf-grenoble.fr (amazone1.ujf-grenoble.fr [193.54.238.254]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l2FEwbo0023781 for ; Thu, 15 Mar 2007 15:58:37 +0100 Received: from tana2.ujf-grenoble.fr (tana2.ujf-grenoble.fr [152.77.24.22]) by amazone1.ujf-grenoble.fr (8.13.7/8.13.7/Configured by JE 21 07 2006) with ESMTP id l2FEuO9B008486; Thu, 15 Mar 2007 15:56:24 +0100 (CET) Received: from localhost (unknown [127.0.0.1]) by tana2.ujf-grenoble.fr (Postfix) with ESMTP id 04F05250432; Thu, 15 Mar 2007 15:56:24 +0100 (CET) X-Virus-Scanned: Scanned on tana2.ujf-grenoble.fr Received: from tana2.ujf-grenoble.fr ([127.0.0.1]) by localhost (tana2.ujf-grenoble.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TsvdFf8eqQZ8; Thu, 15 Mar 2007 15:56:23 +0100 (CET) Received: from tibre1.ujf-grenoble.fr (tibre1.ujf-grenoble.fr [152.77.18.86]) by tana2.ujf-grenoble.fr (Postfix) with ESMTP id C8AE7250431; Thu, 15 Mar 2007 15:56:23 +0100 (CET) Received: from bruch.ujf-grenoble.fr (bruch.ujf-grenoble.fr [193.54.241.15]) by tibre1.ujf-grenoble.fr (8.13.3/8.13.3) with ESMTP id l2FEuObO016672; Thu, 15 Mar 2007 15:56:24 +0100 (CET) (envelope-from san.vu-ngoc@ujf-grenoble.fr) Received: from localhost (localhost [127.0.0.1]) by bruch.ujf-grenoble.fr (Postfix) with ESMTP id 78B0D4F9A3; Thu, 15 Mar 2007 15:56:23 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at fourier.ujf-grenoble.fr Received: from bruch.ujf-grenoble.fr ([127.0.0.1]) by localhost (bruch.ujf-grenoble.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id GMz8sdFMeaKu; Thu, 15 Mar 2007 15:56:22 +0100 (CET) Received: from [193.48.255.250] (ifpoolext7.ujf-grenoble.fr [193.48.255.250]) by bruch.ujf-grenoble.fr (Postfix) with ESMTP id A3FD94F94A; Thu, 15 Mar 2007 15:56:22 +0100 (CET) Message-ID: <45F95E97.9010300@ujf-grenoble.fr> Date: Thu, 15 Mar 2007 15:56:23 +0100 From: Vu Ngoc San User-Agent: IceDove 1.5.0.10 (X11/20070307) MIME-Version: 1.0 To: skaller , Caml Mailing List Subject: Re: [Caml-list] dynamically finding libraries References: <45F94D57.9010009@ujf-grenoble.fr> <1173969084.11071.16.camel@rosella.wigram> In-Reply-To: <1173969084.11071.16.camel@rosella.wigram> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Miltered: at concorde with ID 45F95F1D.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; dlopen:01 ocaml:01 dynamically:01 compile:01 caml-list:01 symbolic:01 lazy:02 elf:03 library:03 library:03 usb:94 paths:05 install:05 ecrit:06 linked:06 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. >