From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 04E02BBAF for ; Tue, 16 Feb 2010 23:34:32 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArMEACasektV2gB5Zmdsb2JhbACDBZgrDQsICBQjrSmPa4EwglBbBIle X-IronPort-AV: E=Sophos;i="4.49,486,1262559600"; d="scan'208";a="44925790" Received: from emailfrontal2.citycable.ch ([85.218.0.121]) by mail3-smtp-sop.national.inria.fr with SMTP; 16 Feb 2010 23:34:31 +0100 Received: from [192.168.0.12] (unknown [85.218.92.99]) (Authenticated sender: guillaume.yziquel@citycable.ch) by emailfrontal2.citycable.ch (Postfix) with ESMTPA id ED8DCB1045F; Tue, 16 Feb 2010 23:34:28 +0100 (CET) Message-ID: <4B7B1D97.4020706@citycable.ch> Date: Tue, 16 Feb 2010 23:35:03 +0100 From: Guillaume Yziquel Reply-To: guillaume.yziquel@citycable.ch User-Agent: Mozilla-Thunderbird 2.0.0.22 (X11/20090707) MIME-Version: 1.0 To: OCaml List Subject: Re: Embedding OCaml - manual not up to date. References: <4B7B120E.9010007@citycable.ch> In-Reply-To: <4B7B120E.9010007@citycable.ch> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Spam: no; 0.00; guillaume:01 guillaume:01 ocaml:01 ocaml:01 compilation:01 ocamlopt:01 -output-obj:01 cmxa:01 cmx:01 cmxa:01 myprog:01 usr:01 lib:01 -lunix:01 pervasives:01 Guillaume Yziquel a =C3=A9crit : > Hi. >=20 > The manual is not up to date when it comes to embedding OCaml code into= =20 > C code. >=20 > http://caml.inria.fr/pub/docs/manual-ocaml/manual032.html#toc134 >=20 > Specifically the section >=20 > 18.7.5 Embedding the Caml code in the C code >=20 > and the piece of compilation code I'm having trouble with is the follow= ing: >=20 >> ocamlopt -output-obj -o camlcode.o unix.cmxa other .cmx and=20 >> .cmxa files >> cc -o myprog C objects and libraries \ >> camlcode.o -L/usr/local/lib/ocaml -lunix -lasmrun >=20 > This code complains about missing symbols from pervasives. >=20 > So I adapt it by compiling with pervasives.cmx, and I get >=20 >> ocamlopt -output-obj -o camlcode.o pervasives.cmx >> ld: /usr/lib/ocaml/pervasives.o: No such file: No such file or directo= ry >> File "caml_startup", line 1, characters 0-1: >> Error: Error during linking >> make: *** [camlcode.o] Erreur=20 >=20 > But I cannot find pervasives.o anywhere. Well I found it in stdlib.a, but looking back at the thread started by=20 Aaron Bohannon mid-december http://caml.inria.fr/pub/ml-archives/caml-list/2009/12/3375527140f0de987a= 9dc6d2553990c8.en.html it seems to me that there is little need for the -output-obj option, as=20 shown in the manual. Why not document the embedding by simply compiling=20 the C code tha provides the main function, which itself calls=20 caml_startup, and then linking it with the .cmx with ocamlopt? Why the=20 need for -output-obj, libasmrun.a, etc...? --=20 Guillaume Yziquel http://yziquel.homelinux.org/