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 VAA04994; Mon, 4 Mar 2002 21:00:04 +0100 (MET) 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 VAA05460 for ; Mon, 4 Mar 2002 21:00:02 +0100 (MET) Received: from mail11.speakeasy.net (mail11.speakeasy.net [216.254.0.211]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g24K01v03298 for ; Mon, 4 Mar 2002 21:00:01 +0100 (MET) Received: (qmail 23586 invoked from network); 4 Mar 2002 19:59:59 -0000 Received: from unknown (HELO harry) ([64.81.246.34]) (envelope-sender ) by mail11.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 4 Mar 2002 19:59:59 -0000 Message-ID: <009001c1c3b7$2146bcc0$0200a8c0@harry> From: "Harry Chomsky" To: "Warp" , "OCaml" References: <012301c1bf78$20abdf40$6500a8c0@warp> Subject: Re: [Caml-list] Dynamic Linking Bug Date: Mon, 4 Mar 2002 11:59:44 -0800 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 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4807.1700 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > It comes when trying to Dynlink a CMA build with flags : > > -cclib -lmylib -dllib -lmylib > > Dynlink.loadfile "mylib.cma" > it prints the Win32 error message "Dynamic library not found", which is > quite annoying because the name of the DLL is missing. Seems like the > dynlink_open_lib should fail with more informations (at least under Win32 : > caml_dlerror does not include the name of the module ). > So i did make it fail with the name of the library Dynlink is trying to load > , and it is "-lwin32.dll" ( seems like Dynlink doesn't like -l notation ). This looks like a bug in dynlink.ml. The line: Dll.open_dlls lib.lib_dllibs should be changed to something like this: Dll.open_dlls (List.map Dll.extract_dll_name lib.lib_dllibs) Can this fix be incorporated into the next OCaml release? > Another problem with dynamic linking is that it can't be used with "-custom" > mode. When you write a DLL, you need to use caml functions to register > roots, allocations, etc... To enable access to theses functions, you need to > link with ocamlrun.lib which contains links to ocamlrun exported functions. > So when your runtime is not ocamlrun, the calls to caml functions crash. This is a problem with "-custom", and it is also a problem with "-use-runtime". Also it applies to the standard load-time dynamic linking as well as runtime use of Dynlink. Right now OCaml programmers have two choices: 1) Use dynamic linking along with the standard ocamlrun.exe; or 2) Use a custom runtime, either with "-custom" or with "-make-runtime" + "-use-runtime", and statically link in all the libraries you'll need. It would be nice if there were a way to mix and match between these two approaches. I'm also curious whether anyone on the OCaml team sees this as a possible future enhancement, or if it's just not possible. Specifically, since we're using OCaml to build Windows applications, we want to have our OCaml runtime use the "windows subsystem" instead of the "console subsystem". This is easy if we link using "-custom", but we haven't found a good way to do it with dynamic linking. Our only option is to keep two versions of ocamlrun.exe with the same name in different directories, one flagged for the console subsystem and one flagged for the windows subsystem, and change the search path to find one or the other depending which kind of OCaml program we want to run. It would be much nicer if we could name the windows-subsystem runtime "ocamlrunw.exe" instead -- but then DLLs won't find it. ------------------- 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