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 VAA19151; Wed, 28 Apr 2004 21:34:05 +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 VAA19140 for ; Wed, 28 Apr 2004 21:34:04 +0200 (MET DST) X-SPAM-Warning: Sending machine is listed in blackholes.five-ten-sg.com Received: from postfix3-2.free.fr (postfix3-2.free.fr [213.228.0.169]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i3SJY3YM019181 for ; Wed, 28 Apr 2004 21:34:03 +0200 Received: from warp (chateaudeau-4-82-225-176-25.fbx.proxad.net [82.225.176.25]) by postfix3-2.free.fr (Postfix) with SMTP id 34C1DC952; Wed, 28 Apr 2004 21:34:02 +0200 (CEST) Message-ID: <015d01c42d57$74bfad60$19b0e152@warp> From: "Nicolas Cannasse" To: "Yaron Minsky" , References: <40551.141.155.88.179.1083177798.squirrel@minsky-primus.homeip.net> Subject: Re: [Caml-list] Byte code and dynamic linking of C libraries Date: Wed, 28 Apr 2004 21:31:47 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Miltered: at concorde by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; cannasse:01 warplayer:01 caml-list:01 dynamically:01 statically:01 dlopen:01 dlclose:01 segfault:01 api:01 ocamlrun:01 ocamlrun:01 api:01 librairies:01 dynlinked:01 cannasse:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > I've got some code that dynamically links in a C library. The code works > just fine when I compile to native code, but blows up when I compile to > bytecode. Just to be clear, the dynamic linking I'm doing happens > entirely on the C side: I've got a c library that is linked in > statically, and the dlopen and dlclose calls all happen within that C > library. When I try this trick in bytecode, I get a segfault. > > So, any ideas as to what I need to do to make dynamic linking and byte > code to play nicely together? Is the C library you're dynlinking is using Caml API ? I got such problems, because when linking (under windows) to ocamlrun.lib, your C dll is referencing ocamlrun.dll wich is the caml api library for the bytecode interpreter (before it was ocamlrun.exe but now it's a separate dll so the custom mode works well since both the exe and the dll are using the same code). The solution I know is to link staticly all the C librairies in native code. One other is that your dynlinked C library redirects its calls to the Caml API through the C library which is loading it. Regards, Nicolas Cannasse ------------------- 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