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 02F78BCAC for ; Tue, 24 May 2005 07:07:06 +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 j4O575L4001107 for ; Tue, 24 May 2005 07:07:05 +0200 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 HAA25911 for ; Tue, 24 May 2005 07:07:04 +0200 (MET DST) Received: from publilogics.com (pouic.publilogics.com [213.186.50.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with SMTP id j4O574Xq012158 for ; Tue, 24 May 2005 07:07:04 +0200 Received: (qmail 19270 invoked from network); 24 May 2005 05:07:03 -0000 Received: from unknown (HELO PWARP) ([61.213.94.147]) (envelope-sender ) by pouic.publilogics.com (qmail-ldap-1.03) with SMTP for ; 24 May 2005 05:07:03 -0000 Message-ID: <001d01c5601e$531fb740$0d05a8c0@PWARP> From: "Nicolas Cannasse" To: "Robert Roessler" , References: <4292A58D.207@rftp.com> Subject: Re: [Caml-list] ocamlopt and *using* DLLs Date: Tue, 24 May 2005 14:06:19 +0900 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.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 X-j-chkmail-Score: MSGID : 4292B678.001 on nez-perce : j-chkmail score : X : 0/40 1 X-Miltered: at concorde with ID 4292B679.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 4292B678.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; cannasse:01 warplayer:01 caml-list:01 ocamlopt:01 dlls:01 beginners:01 dlls:01 ocamlopt:01 compiler:01 ocamlc:01 lib:01 model:01 ocamlc:01 stub:01 ocaml: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: > I tried this on the beginners list, but may not have been asking the > right question(s)... :) > > 1) Can DLLs appear as input to the ocamlopt compiler like they can > with ocamlc? The manual says "yes": "Arguments ending in .o, .a or y > .so (.obj, .lib and .dll under Windows) are assumed to be C object > files and libraries. They are linked with the program." > > I get "ocamlopt.opt: don't know what to do with ml_scintilla.dll." > > 2) If DLLs can in fact be used with ocamlopt, is the model the same as > with ocamlc? In particular, > > 2a) can I use them *without* stub libraries? > > 2b) can I in general expect that an app that works well with ocamlc > and a collection of OCaml cma libs and compiled DLLs (LablGTK and > associated runtime) will work with ocamlopt - assuming that I generate > and replace cmo/cma files with cmx/cmxa files? > > Robert Roessler > roessler@rftp.com > http://www.rftp.com I was not maybe clear enough on the beginner list :) 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. Nicolas Cannasse