From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id QAA01933 for caml-redistribution; Sat, 24 Oct 1998 16:54:20 +0200 (MET DST) 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 LAA08710 for ; Fri, 23 Oct 1998 11:30:58 +0200 (MET DST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.8.7/8.8.7) with ESMTP id LAA02681; Fri, 23 Oct 1998 11:30:49 +0200 (MET DST) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id LAA05837; Fri, 23 Oct 1998 11:30:49 +0200 (MET DST) Message-ID: <19981023113049.35013@pauillac.inria.fr> Date: Fri, 23 Oct 1998 11:30:49 +0200 From: Xavier Leroy To: Friedman Roy , caml-list@inria.fr Subject: Re: Linking caml generated object in NT References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.89.1 In-Reply-To: ; from Friedman Roy on Tue, Oct 20, 1998 at 03:29:08PM +0200 Sender: weis > I am trying to link object files generated by ocamlopt with object files > generated by the C compiler (cl for instance) and got a lot of unknown > symbols errors. I tried adding some or all of the libraries in the lib > directory, and still a few symbols remained unknown. Is there a list of > libraries one has to link with to make this work. The main difficulty is that some glue code is generated at link-time when you lin with ocamlopt, so in general you can't just link together the .obj files produced by the ocamlopt compiler using another linker. Your best bet is to use the "-output_obj" option to build a self-contained .lib file with all your compiled Caml code + the glue code generated at link-time + the OCaml runtime library: ocamlopt -output_obj -o mycamlcode.lib Then, you need to provide a main() function in C to start the Caml code. The following should do: int main(int argc, char ** argv) { caml_startup(argv); return 0; } Finally, use the NuMega linker to link together mycamlcode.lib, the C libraries used by your Caml code, and the main() function above. See the "Embedding the Caml code in the C code" and "Main program in C" sections of the chapter "Interfacing C with Objective Caml" of the manual for more details. I haven't tried -output_obj under Windows in a long time, so the above might not be 100% accurate, but I hope it will help. - Xavier Leroy