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 SAA26606; Thu, 23 Sep 2004 18:57:30 +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 SAA26266 for ; Thu, 23 Sep 2004 18:57:29 +0200 (MET DST) Received: from slinky.cs.nyu.edu (SLINKY.CS.NYU.EDU [128.122.20.14]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id i8NGvShc032150 for ; Thu, 23 Sep 2004 18:57:29 +0200 Received: from localhost (localhost [127.0.0.1]) by slinky.cs.nyu.edu (8.12.10+Sun/8.12.10) with ESMTP id i8NGvQoQ015734; Thu, 23 Sep 2004 12:57:26 -0400 (EDT) Date: Thu, 23 Sep 2004 12:57:26 -0400 (EDT) From: Igor Pechtchanski Reply-To: caml-list@inria.fr To: matthieu.dubuget@libertysurf.fr cc: =?iso-8859-1?Q?caml-list?= Subject: Re: [Caml-list] =?iso-8859-1?Q?DLL_(windows)_creation_problem?= In-Reply-To: Message-ID: References: Importance: Normal MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Scanned-By: MIMEDefang 2.39 X-Miltered: at concorde with ID 41530078.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; nyu:99 caml-list:01 matthieu:01 dubuget:01 camlers:01 printf:01 printf:01 callback:01 char:01 stdio:01 fflush:01 stdout:01 fflush:01 stdout:01 ocamlc:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Thu, 23 Sep 2004, matthieu.dubuget wrote: > Hello camlers! > > I experience a strange problem with the following on windows 98. > > I have the following files: > > =============== dac.ml =========================== > let affiche dac = > Printf.printf "%d\n" dac > ================================================== > > =========== ms_dac.h ============================= > void ms_dac_init (); > int ms_dac_init_ok (void); > ================================================== > > =========== ms_dac.c ============================= > #include "ms_dac.h" > #include > > static int ms_dac_init_done = 0; > > void ms_dac_init (){ > char *vide = 0l; > if (!ms_dac_init_done){ > caml_startup (&vide); > ms_dac_init_done = 1; > } > } > int ms_dac_init_ok (void){ > return ms_dac_init_done; > } > ================================================== > > =========== ms_dac.def =========================== > EXPORTS > ms_dac_init > ms_dac_init_ok > ================================================== > > ========== t.c =================================== > #include > #include "ms_dac.h" > > int main (){ > int ok; > ok = ms_dac_init_ok(); > printf ("%d\n",ok); > fflush(stdout); > ms_dac_init(); > ok = ms_dac_init_ok(); > printf ("%d\n",ok); > fflush(stdout); > return 0; > } > ================================================== > > C:\test>ocamlc -v > ocamlc -v > The Objective Caml compiler, version 3.08.0 > Standard library directory: c:\ocaml\lib > > C:\test>ocamlopt -output-obj -o dacl.obj dac.ml > > ocamlopt -output-obj -o dacl.obj dac.ml > > C:\test>ocamlopt -c ms_dac.c > > ocamlopt -c ms_dac.c > ms_dac.c > > C:\test>link -nologo -dll -out:ms_dac.dll -def:ms_dac.def > dacl.obj ms_dac.obj -libpath:c:\ocaml\lib libasmrun.lib > link -nologo -dll -out:ms_dac.dll -def:ms_dac.def dacl.obj > ms_dac.obj -libpath:c:\ocaml\lib libasmrun.lib > Creating library ms_dac.lib and object ms_dac.exp > > C:\test>cl -o t.exe -nologo -Ox -MT ms_dac.lib t.c > cl -o t.exe -nologo -Ox -MT ms_dac.lib t.c > t.c > > C:\test>t.exe > t.exe > 0 > <------------------- At this step I get an error from Windows The dependent DLL should be in the PATH (instead of LD_LIBRARY_PATH). Windows should tell you which DLL is missing (I suspect it's the one that contains the Printf module). > If I modify the function definition (that uses Printf.printf) in > the ml file, their is no more error. > > let affiche dac = > print_int dac That's no surprise -- "print_int" is built into the ocaml binary, so your DLL is not dependent on other DLLs anymore. > I suspect a conflict, or a missing library, but I can't find out what is > going on exactly. > > On linux, this gives the following with the original files: > > $ ocamlc -v > The Objective Caml compiler, version 3.08.1 > Standard library directory: /usr/lib/ocaml/3.08 > $ ocamlopt -output-obj -o dac1.o dac.ml > $ ocamlopt -c ms_dac.c > $ gcc -shared -o libdac.so dac1.o ms_dac.o > -L/usr/lib/ocaml/3.08 -lasmrun > $ gcc -o t libdac.so t.c -lm -ldl > $ LD_LIBRARY_PATH=. ./t > 0 > 1 > $ > > Thanks in advance > Matthieu Dubuget FWIW, I've just posted a Cygwin ocaml package version that supports dynamic linking and should let you use the above Linux transcript almost verbatim (only tested on WinXP for now, see ). It's not on the mirrors yet, but feel free to test it out, and, if you do, please report the results to me or the Cygwin list (). Igor Pechtchanski Volunteer O'Caml maintainer for Cygwin. -- http://cs.nyu.edu/~pechtcha/ |\ _,,,---,,_ pechtcha@cs.nyu.edu ZZZzz /,`.-'`' -. ;-;;,_ igor@watson.ibm.com |,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski, Ph.D. '---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow! "Happiness lies in being privileged to work hard for long hours in doing whatever you think is worth doing." -- Dr. Jubal Harshaw ------------------- 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