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 TAA12349; Thu, 10 Jun 2004 19:28:02 +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 TAA12437 for ; Thu, 10 Jun 2004 19:28:01 +0200 (MET DST) From: peter.ilberg@ni.com Received: from mailserver01-us.natinst.com (mailserver01-us.natinst.com [130.164.14.247]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i5AHS0SH000403 for ; Thu, 10 Jun 2004 19:28:00 +0200 Received: from postoffice2.natinst.com ([130.164.46.199]) by mailserver01-us.natinst.com (Lotus Domino Release 6.5.1) with ESMTP id 2004061012280042-24972 ; Thu, 10 Jun 2004 12:28:00 -0500 In-Reply-To: <20040610190443.A10900@pauillac.inria.fr> To: caml-list@inria.fr Subject: Re: [Caml-list] Linking native ocaml object files into C app on Windows MIME-Version: 1.0 X-Mailer: Lotus Notes Release 6.0.2CF2 July 23, 2003 Message-ID: Date: Thu, 10 Jun 2004 12:28:00 -0500 X-MIMETrack: Serialize by Router on PostOffice2/AUS/M/NIC(Release 6.5.1|January 21, 2004) at 06/10/2004 12:27:59 PM, Serialize complete at 06/10/2004 12:27:59 PM, Itemize by SMTP Server on MailServer01-US/AUS/H/NIC(Release 6.5.1|January 21, 2004) at 06/10/2004 12:28:00 PM, Serialize by Router on MailServer01-US/AUS/H/NIC(Release 6.5.1|January 21, 2004) at 06/10/2004 12:28:01 PM, Serialize complete at 06/10/2004 12:28:01 PM Content-Type: text/plain; charset="US-ASCII" X-Miltered: at concorde with ID 40C89A20.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 2004:99 caml-list:01 nologo:01 ocamlopt:01 -output-obj:01 ocamlopt:01 -output-obj:01 ocaml:01 ocaml:01 caml:01 msvc:01 msvc:01 lib:01 lib:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk That's it! Everything builds, links and runs fine! Thank you! Peter Xavier Leroy 06/10/2004 12:04 PM To: peter.ilberg@ni.com cc: Subject: Re: [Caml-list] Linking native ocaml object files into C app on Windows > I'm trying to add some ocaml code (a simple lexer/parser) to an existing C > application and I'm having problems linking the whole thing on Windows. > Needless to say, everything works fine under Unix (Mac OS X). I'm using > the MSVC version of ocaml. > > Here's are the commands that I use to build the whole thing: > > cl /c /nologo /MT /I "C:\Program Files\Objective Caml\lib" main.c > ocamllex lexer.mll > ocamlopt -c -output-obj lexer.ml -o lexer.obj Three problems: 1) -c turns linking off, while you really want to do a (partial) link here. 2) The compilation of lexer.ml already produces lexer.obj, so you give lexer.obj both as input and as output to the partial linker, which can break things. 3) With the MSVC port, the output of the partial linker is a .lib file, not a .obj file, so it would be prudent to name the output appropriately. Try this instead: ocamlopt -output-obj -o lexer.lib lexer.ml Hope this helps, - Xavier Leroy ------------------- 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