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 WAA11292; Mon, 22 Apr 2002 22:29:35 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id WAA11301 for ; Mon, 22 Apr 2002 22:29:34 +0200 (MET DST) Received: from sunny.pacific.net.au (sunny.pacific.net.au [203.25.148.40]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g3MKTWj26887 for ; Mon, 22 Apr 2002 22:29:32 +0200 (MET DST) Received: from wisma.pacific.net.au (wisma.pacific.net.au [210.23.129.72]) by sunny.pacific.net.au with ESMTP id g3MKTUXt007658; Tue, 23 Apr 2002 06:29:30 +1000 (EST) Received: from ozemail.com.au (ppp211.dyn71.pacific.net.au [202.7.71.211]) by wisma.pacific.net.au with ESMTP id GAA00894; Tue, 23 Apr 2002 06:29:28 +1000 (EST) Message-ID: <3CC472A7.5070901@ozemail.com.au> Date: Tue, 23 Apr 2002 06:29:27 +1000 From: John Max Skaller User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.2.1) Gecko/20010901 X-Accept-Language: en-us MIME-Version: 1.0 To: Richard Nyberg CC: caml-list@inria.fr Subject: Re: [Caml-list] shared libraries [pcre-ocaml] References: <20020422103046.B21430@gromit.it.su.se> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Richard Nyberg wrote: >Hello I've some problems with ocaml and shared libraries. I'm running >a recent FreeBSD-4-STABLE and have ocaml 3.04 installed from ports. > >pcre-ocaml is built with shared libraries and is installed in >/usr/local/lib/ocaml/site-lib/pcre > >ocaml's ld.conf contains the following lines: > >----------ld.conf >/usr/local/lib/ocaml >/usr/local/lib/ocaml/labltk >/usr/local/lib/ocaml/site-lib/pcre >---------- > >If I use ocamlopt to compile everything is fine but when I use ocamlc >the following error occurs. > >----------compiling ># ocamlc -o myprog -I +site-lib/netstring -I +site-lib/pcre \ > unix.cma pcre.cma netstring.cma myprog.ml > >Error on dynamically loaded library: Shared object "libpcre.so.0" not found >---------- > >I ran truss to see the syscalls made by ocamlc (relevant bit below) and >to me it seems as if it finds dllpcre.so but not libpcre.so.0 on which >dllpcre.so depends. However if I run ldconfig to include pcre-ocaml's >installation directory everything works just fine. > >So, should I have to use ldconfig or is there something wrong? > Argg... crappy unix hackery. The dynamic loader typically searches for relative filenames in the ldconfig'd search path, augmented by LD_PATH environment variable. Absolute filenames just get opened directly. You can see below that ocaml is manually stat'ing dllpcre.so in places it knows about before doing a dlopen on an absolute filename. Unfortunately, it depends on another shared lib, and ld is searching for that by itself. It doesn't find it, since /usr/local/ocaml/site-lib/pcre isn't on the ldconfig path. This suggests the binding to dllpcre.so.0 installed in dllpcre.so is a relative filename. So does the ld.conf file above .. and if you run ldconfig on that, of course now the load works. Running ldconfig on the ld.conf file will work. Another solution is simply to install dllpcre.so.0 in /usr/local/lib. Another is to put a symbolic link there. None of these solutions is very good .. [Check out Python's mechanism for a much saner system ..] > >---------truss >stat("/usr/local/lib/ocaml/site-lib/netstring/dllpcre.so",0xbfbff524) ERR#2 'No >such file or directory' >stat("/usr/local/lib/ocaml/site-lib/pcre/dllpcre.so",0xbfbff524) = 0 (0x0) >sigprocmask(0x1,0x28072c80,0xbfbff4e4) = 0 (0x0) >open("/usr/local/lib/ocaml/site-lib/pcre/dllpcre.so",0x0,056) = 6 (0x6) >fstat(6,0xbfbff494) = 0 (0x0) >read(0x6,0xbfbfe464,0x1000) = 4096 (0x1000) >mmap(0x0,12288,0x5,0x2,6,0x0) = 672776192 (0x2819c000) >mmap(0x2819e000,4096,0x3,0x12,6,0x1000) = 672784384 (0x2819e000) >close(6) = 0 (0x0) >access("/usr/local/lib/ocaml/contrib/libpcre.so.0",0) ERR#2 'No such file or dir >ectory' >access("/usr/lib/libpcre.so.0",0) ERR#2 'No such file or director >y' >access("/usr/lib/compat/libpcre.so.0",0) ERR#2 'No such file or director >y' >access("/usr/X11R6/lib/libpcre.so.0",0) ERR#2 'No such file or director >y' >access("/usr/local/lib/libpcre.so.0",0) ERR#2 'No such file or director >y' >access("/usr/lib/elf/libpcre.so.0",0) ERR#2 'No such file or director >y' >access("/usr/lib/libpcre.so.0",0) ERR#2 'No such file or director >y' >------------- > > -Richard >------------------- > -- John Max Skaller, mailto:skaller@ozemail.com.au snail:10/1 Toxteth Rd, Glebe, NSW 2037, Australia. voice:61-2-9660-0850 ------------------- 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