From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 D9A18BCAB for ; Fri, 27 May 2005 03:48:37 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j4R1mb8v032104 for ; Fri, 27 May 2005 03:48:37 +0200 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 DAA24450 for ; Fri, 27 May 2005 03:48:36 +0200 (MET DST) Received: from smtp803.mail.sc5.yahoo.com (smtp803.mail.sc5.yahoo.com [66.163.168.182]) by concorde.inria.fr (8.13.0/8.13.0) with SMTP id j4R1mZbC032101 for ; Fri, 27 May 2005 03:48:36 +0200 Received: from unknown (HELO ?192.168.1.100?) (rftp@pacbell.net@63.194.18.166 with plain) by smtp803.mail.sc5.yahoo.com with SMTP; 27 May 2005 01:48:34 -0000 Message-ID: <42967CD7.70605@rftp.com> Date: Thu, 26 May 2005 18:50:15 -0700 From: Robert Roessler Organization: Robert's High-performance Software User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Caml-list Subject: Re: [Caml-list] ocamlopt and *using* DLLs References: <4292A58D.207@rftp.com> <001d01c5601e$531fb740$0d05a8c0@PWARP> In-Reply-To: <001d01c5601e$531fb740$0d05a8c0@PWARP> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 42967C75.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 42967C73.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 ocamlopt:01 dlls:01 cannasse:01 ocaml:01 api:01 bytecode:01 api:01 ocamlrun:01 ocamlrun:01 compilation:01 bytecode:01 initialized:01 ocaml:01 compilation:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.2 X-Spam-Level: Nicolas Cannasse wrote: > The main problem is that your DLL need to call Ocaml API, which it is linked > with. > > In bytecode there is no problem since the whole API is inside ocamlrun.dll > so your DLL and ocamlrun.exe will simply use this API dll together. > In native compilation however there is no more ocamlrun.dll, since the API > is staticly linked into your executable. That means that your DLL that was > working in bytecode will load ocamlrun.dll and call it while your executable > is calling staticly linked API. This will result quite quickly in a crash > since ocamlrun.dll is not initialized correctly. > > The only possible way to get the DLL working is to patch it so it loads its > API inside your.exe and not inside ocamlrun.dll. But then you will need a > different version of the DLL for each application (!). It would be nice if > OCaml could provide the equivalent of ocamlrun.dll for the native > compilation mode. Thanks for the explanation of the key difference between the models, Nicolas! I have this running just fine now, and it is not really as grim as you make it sound above. :) Since my DLL really only exists to provide an interface between OCaml and C-land, I just followed the model used by LablGTK, and build that interface one of two ways: "dllscintilla.dll" for bytecode, and "libscintilla.lib" for native. Robert Roessler roessler@rftp.com http://www.rftp.com