From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 1C0DEBC37 for ; Thu, 31 Dec 2009 00:30:15 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AiADAEZxO0tV2gB5h2dsb2JhbACDa5UegkcBAQEKCwgHFa0CjWuBLYEOgSBWBIkn X-IronPort-AV: E=Sophos;i="4.47,477,1257116400"; d="scan'208";a="40131698" Received: from emailfrontal2.citycable.ch ([85.218.0.121]) by mail2-smtp-roc.national.inria.fr with SMTP; 31 Dec 2009 00:30:14 +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 838B5B103F6; Thu, 31 Dec 2009 00:30:10 +0100 (CET) Message-ID: <4B3BE288.4030701@citycable.ch> Date: Thu, 31 Dec 2009 00:30:16 +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: rouanvd@softwarerealisations.com Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] problem creating .cma library References: <56670.41.177.16.252.1262195331.squirrel@41.177.16.252> In-Reply-To: <56670.41.177.16.252.1262195331.squirrel@41.177.16.252> 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 mingw:01 toolchain:01 mylib:01 stub:01 marshalling:01 ocaml:01 stdio:01 mlvalues:01 mylib:01 camlprim:01 stub:01 camlparam:01 rouanvd@softwarerealisations.com a =C3=A9crit : > Hi everyone. Hi. > I am using ocaml 3.11.0 with the MingW toolchain on windows (vista). Cannot help you much there. > Now I create the mylib_stub.c file which contains the marshalling code > between the libmylib.dll library and ocaml. This file contains the > following C code: >=20 > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > #include > #include > #include "../mylib/mylib.h" >=20 > CAMLprim value > my_print_stub(value v) { CAMLparam1(v); /* is missing here, for garbage collection purposes. */ > char* str =3D (char*)String_val( v ); /* You do not need the right-hand side (char*) casting. */ > my_print( str ); >=20 > return Val_unit; > } > When I finaly build the test ocaml app which is supposed to use the > mylib.cma library, ocamlc tells me: >=20 > "Unbound module Mylib" Firs of all, mylib.cma is simply an archive of OCaml modules. It may=20 contain multiple modules, and might not contain a module called Mylib. You have to ensure that mylib.cmo is included in mylib.cma. Moreover,=20 when you create mylib.cma, you also need a compiled interface, i.e. a=20 mylib.cmi file. It's an interface for mylib.cmo. Without it, there's no=20 description of module Mylib in mylib.cma. > The command used to compile the test app is >=20 > ocamlc -verbose mylib.cma -c Main.ml You've got something fundamentally wrong here: Out of main.ml (lower case for the the first letter), you first create a=20 main.cmo file. And also a main.mli file with ocamlc -i. You compile the=20 main.mli file to main.cmi. Then you create the mylib.cma archive from=20 main.cmo and main.cmi. And mylib.cma will contain the module Main. Not the module Mylib. > The Main.ml file contains the following code: >=20 > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > open Mylib >=20 > let main () =3D > my_print "my_print =3D ok" >=20 >=20 > main () > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Here, you're declaring the submodule Mylib of the module Main. Also=20 known as Main.Mylib. Not as Mylib. > Is there a way to verify that the .cma library was created correctly? There are some tools, such as ocamldumpobj and ocamlobjinfo. Forgot=20 which one applies to .cmas. > I had to install flexlink for ocaml to get the dll linking to work on > windows. Can't help you here. > Kind regards > Rouan. All the best, --=20 Guillaume Yziquel http://yziquel.homelinux.org/