From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id EAA05219; Wed, 24 Sep 2003 04:46:40 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id EAA31884 for ; Wed, 24 Sep 2003 04:46:39 +0200 (MET DST) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h8O2kb509603 for ; Wed, 24 Sep 2003 04:46:37 +0200 (MET DST) Received: from localhost (suiren.kurims.kyoto-u.ac.jp [130.54.16.25]) by kurims.kurims.kyoto-u.ac.jp (8.9.3p2-20030924/3.7W) with ESMTP id LAA14601; Wed, 24 Sep 2003 11:44:43 +0900 (JST) To: Narayanan.Krishnamurthy@motorola.com Cc: caml-list@inria.fr Subject: Re: [Caml-list] Having problems with '-rpath' or '-rpath-link' to ocamlopt In-Reply-To: <3F6F367E.C0E7B250@motorola.com> References: <3F6F367E.C0E7B250@motorola.com> X-Mailer: Mew version 1.94.2 on Emacs 21.2 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20030924114443R.garrigue@kurims.kyoto-u.ac.jp> Date: Wed, 24 Sep 2003 11:44:43 +0900 From: Jacques Garrigue X-Dispatcher: imput version 20000228(IM140) X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 ocamlopt:01 jacques:01 narayanan:01 narayanan:01 pcre:01 libpcre:01 usr:01 libpcre:01 pcre:01 usr:01 ocamlopt:01 -rpath:01 -lpcre:01 run-time:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk From: Narayanan Krishnamurthy Hi, > I have two versions of the PCRE "C" libpcre.so > libraries. Let us say that the locations > of the "C" libraries are as follows. > > a) v1.0 : /usr/local/lib/libpcre.so > b) v2.0 : /mylocal/libpcre.so > > I've built the ocaml pcre package (5.02: pcre.cmxa and pcre.cma) > using the "C" v2.0 shared library /mylocal/libpcre.so. > I have pcre.cmxa in my current working directory. > > With my LD_LIBRARY_PATH set as > LD_LIBRARY_PATH = /lib:/usr/lib:/usr/local/lib > I now run > a) ocamlopt -o myexec pcre.cmxa myexec.o \ > -cclib -rpath/mylocal -cclib -lpcre > > and find that 'myexec' has the /usr/local/lib/libpcre.so > as the run-time shared library instead of > /mylocal/libpcre.so (I use 'ldd' on 'myexec') People have already answerred about how LD_LIBRARY_PATH overrides everything else. Here is the relevent section from the ld.so.1 man page on SunOS 5.8. The runtime linker uses a prescribed search path for locat- ing the dynamic dependencies of an object. The default search paths are the runpath recorded in the object, fol- lowed by /usr/lib for 32-bit objects or /usr/lib/64 for 64- bit objects. This latter component can be modified using a configuration file created with crle(1). The runpath is specified when the dynamic object is constructed using the -R option to ld(1). LD_LIBRARY_PATH can be used to indicate directories to be searched before the default directories. There are a few workarounds to avoid this kind of problems. 1) give different versions of the same library different file names. ELF is intended for that. Most software is installed that way. Then you just need a link from libpcre.so to libpcre.so.2, so that the library will be found at compile time. At runtime, the system will look for libpcre.so.2. (Renaming libpcre.so to libpcre.so.2 is not enough, you must write the name inside the file with the proper linker option, -h for Solaris' ld) 2) As Gerd suggested, if you are root on your machine, rather than setting LD_LIBRARY_PATH, you can set the default library path for the machine. The it will only be considered _after_ the runpath. On solaris you use crle for that. This is often a good idea anyway to add /usr/local/lib to it. Dynamic linking can be a real pain. Hope this helps. Jacques Garrigue ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners