From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 916477F734 for ; Tue, 22 Sep 2015 08:53:00 +0200 (CEST) IronPort-PHdr: 9a23:kJ7hGRedj8PDQHqF80aOj+5slGMj4u6mDksu8pMizoh2WeGdxc6zZR7h7PlgxGXEQZ/co6odzbGG7+a7CCdZucnJmUtBWaIPfidNsd8RkQ0kDZzNImzAB9muURYHGt9fXkRu5XCxPBsdMs//Y1rPvi/6tmZKSV3BPAZ4bt74BpTVx5zukbvip9uIMk4R3GX1SIgxBSv1hD2ZjtMRj4pmJ/R54TryiVwMRd5rw3h1L0mYhRf265T41pdi9yNNp6BprJYYAu3SNp41Rr1ADTkgL3t9pIiy7UGCHkOz4S4zW28MkxdMSzPO7BzgU4255iTzvPB81S3cJsb2QKo5Qxyt6q5qTFnjjyJRZBAj92SCr8VqkKNd6D6sghF7x4mcNIScLuZ/eK/QeN4eQW1pUcNYVigHCYS5OdhcR9EdNPpV+tGu72AFqgGzUEz1XLvi Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=martindemello@gmail.com; spf=Pass smtp.mailfrom=martindemello@gmail.com; spf=None smtp.helo=postmaster@mail-vk0-f52.google.com Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of martindemello@gmail.com) identity=pra; client-ip=209.85.213.52; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="martindemello@gmail.com"; x-sender="martindemello@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of martindemello@gmail.com designates 209.85.213.52 as permitted sender) identity=mailfrom; client-ip=209.85.213.52; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="martindemello@gmail.com"; x-sender="martindemello@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-vk0-f52.google.com) identity=helo; client-ip=209.85.213.52; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="martindemello@gmail.com"; x-sender="postmaster@mail-vk0-f52.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0BdAQCo+QBWmzTVVdFdg3haDwatAoc9iw+GAQKBMwc8EAEBAQEBAQEBEAEBAQEBBgsLCSEugh2CBwEBAQMBEhEdARsdAQMBCwYDAgsNKgICIQEBEQEFARwGEyKHdgEDCgiZW49GgTA+MYtGgWyCeYoSChknDVaEEAEBAQEBAQQBAQEBAQEBFQEFDoZlhH2CUIFQbQeCaYFDBYc0hUl1hEqDKYURhgmBb4FNRocQijqFdBIjgRc4gi+CHR4ziC6BPwEBAQ X-IPAS-Result: A0BdAQCo+QBWmzTVVdFdg3haDwatAoc9iw+GAQKBMwc8EAEBAQEBAQEBEAEBAQEBBgsLCSEugh2CBwEBAQMBEhEdARsdAQMBCwYDAgsNKgICIQEBEQEFARwGEyKHdgEDCgiZW49GgTA+MYtGgWyCeYoSChknDVaEEAEBAQEBAQQBAQEBAQEBFQEFDoZlhH2CUIFQbQeCaYFDBYc0hUl1hEqDKYURhgmBb4FNRocQijqFdBIjgRc4gi+CHR4ziC6BPwEBAQ X-IronPort-AV: E=Sophos;i="5.17,571,1437429600"; d="scan'208";a="178808156" Received: from mail-vk0-f52.google.com ([209.85.213.52]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 22 Sep 2015 08:52:59 +0200 Received: by vkgd64 with SMTP id d64so458178vkg.0 for ; Mon, 21 Sep 2015 23:52:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=XdvN75mH2ARvXlczvpRYbkis6VfxKYjSJpVQn4KRsSk=; b=z1IZcJBgobcR6HgpDK0CAOoyJKrTRYEdG4PZCu2stffwO9cXBUNW4sUCDv49wGm06O 37ymGq4vYOdm642+9liXrQH/8cfh3d6ZrP82PsLYx9UrGkGqiYoQmY2NI4rpu8r+4noT AHu2iqeePoQhaNXKZ5GxUdIHKjpUX9FNgu5puoI5HJFfcJFJNOqmQV3riA5Ge4zXUzyr alIRT6n7lYBVX2sLfH/iGxYCN9qb65QiacTx2POOnB+Wtt946JzueXREo6okp6t1StBU ePnXkub0BSvJZPrrSKXMCcic5QhDLdit1SCzRisPftB4cxuydDTjVbBskRmH5Zbqjm83 T6BA== MIME-Version: 1.0 X-Received: by 10.31.9.81 with SMTP id 78mr2677663vkj.10.1442904778228; Mon, 21 Sep 2015 23:52:58 -0700 (PDT) Received: by 10.103.51.142 with HTTP; Mon, 21 Sep 2015 23:52:58 -0700 (PDT) In-Reply-To: References: Date: Mon, 21 Sep 2015 23:52:58 -0700 Message-ID: From: Martin DeMello To: Gabriel Scherer Cc: OCaml List Content-Type: multipart/alternative; boundary=001a1143c0f6c04ab705205072df Subject: Re: [Caml-list] building and using a library in a subdirectory --001a1143c0f6c04ab705205072df Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Thanks, I didn't realise that. Replacing Puz_plugin.read with Puz.read compiled, but didn't link: + ocamlfind ocamlopt -linkpkg -g -thread -package core_kernel plugins/puz/puz_types.cmx plugins/puz/puz_utils.cmx plugins/puz/puz_bin.cmx plugins/puz/puz_match.cmx types.cmx xword.cmx plugins/puz/puz.cmx file.cmx -o file.native File "_none_", line 1: Error: No implementations provided for the following modules: Bitstring referenced from plugins/puz/puz_bin.cmx Run_mikmatch_pcre referenced from plugins/puz/puz_match.cmx Str referenced from plugins/puz/puz.cmx Pcre referenced from plugins/puz/puz_match.cmx Command exited with code 2. I don't (yet) need dynamic linking; my current main aim with the .mllib setup is to specify the package dependencies for each plugin in its own section of the _tags file, and not have a long list of every plugin's dependencies in the main module. martin On Mon, Sep 21, 2015 at 11:45 PM, Gabriel Scherer wrote: > A .cma or .cmxa archive does not pack its sub-modules under a common > module name: the module name Puz_plugin that you use does not refer to > anything. Accessing any of the constituent modules directly (eg. > Puz_match.foo) should work -- although it may not go through the .cmxa > but directly refer to the compilation unit. > > Note that if "_plugin" is intended to refer to dynamic linking, you > may want to use a .mldylib file instead of .mllib, to be used to > generate a .cmxs file: .cmxa is not suitable for dynamic linking > (while, at the bytecode level, .cma work for both static and dynamic > linking). > > On Tue, Sep 22, 2015 at 8:23 AM, Martin DeMello > wrote: > > If I have my project set up like this: > > > > . > > =E2=94=9C=E2=94=80=E2=94=80 file.ml > > =E2=94=9C=E2=94=80=E2=94=80 plugins > > =E2=94=82 =E2=94=94=E2=94=80=E2=94=80 puz > > =E2=94=82 =E2=94=9C=E2=94=80=E2=94=80 puz_bin.ml > > =E2=94=82 =E2=94=9C=E2=94=80=E2=94=80 puz_match.ml > > =E2=94=82 =E2=94=9C=E2=94=80=E2=94=80 puz.ml > > =E2=94=82 =E2=94=9C=E2=94=80=E2=94=80 puz_plugin.mllib > > =E2=94=82 =E2=94=9C=E2=94=80=E2=94=80 puz_types.ml > > =E2=94=82 =E2=94=94=E2=94=80=E2=94=80 puz_utils.ml > > =E2=94=94=E2=94=80=E2=94=80 _tags > > > > $ cat plugins/puz/puz_plugin.mllib > > Puz Puz_bin Puz_match > > > > This works: > > > > $ ocamlbuild -use-ocamlfind plugins/puz/puz_plugin.cmxa > > Finished, 22 targets (3 cached) in 00:00:03. > > > > My _tags file: > > ------------------------------------------------ > > $ cat _tags > > true: thread,debug > > true: package(core_kernel) > > > > "plugins/puz": include > > > > : package(labltk) > > <**/puz.*>: package(unix), package(str), package(core_kernel), > > package(bitstring), package(mikmatch_pcre) > > <**/*_bin.*>: package(bitstring.syntax), syntax(bitstring) > > <**/*_match.*>: package(mikmatch_pcre), syntax(camlp4o) > > ------------------------------------------------ > > > > But I can't figure out how to use this library in my main program. This > is a > > minimal example of what I'm trying to do, not working of course: > > > > $ cat file.ml > > open Core_kernel.Std > > > > let read fname =3D > > let data =3D In_channel.read_all fname in > > Puz_plugin.read data > > > > $ ocamlbuild -use-ocamlfind file.native > > + ocamlfind ocamlc -c -g -thread -package core_kernel -I plugins/puz -o > > file.cmo file.ml > > File "file.ml", line 5, characters 2-17: > > Error: Unbound module Puz_plugin > > > > martin > --001a1143c0f6c04ab705205072df Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Thanks, I didn't realise that. Replacing Puz_plugin.re= ad with Puz.read compiled, but didn't link:

+ o= camlfind ocamlopt -linkpkg -g -thread -package core_kernel plugins/puz/puz_= types.cmx plugins/puz/puz_utils.cmx plugins/puz/puz_bin.cmx plugins/puz/puz= _match.cmx types.cmx xword.cmx plugins/puz/puz.cmx file.cmx -o file.native<= /div>
File "_none_", line 1:
Error: No implementati= ons provided for the following modules:
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0Bitstring referenced from plugins/puz/puz_bin.cmx
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Run_mikmatch_pcre referenced from plugins/pu= z/puz_match.cmx
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Str referenced = from plugins/puz/puz.cmx
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Pcre r= eferenced from plugins/puz/puz_match.cmx
Command exited with code= 2.

I don't (yet) need dynamic linking; = my current main aim with the .mllib setup is to specify the package depende= ncies for each plugin in its own section of the _tags file, and not have a = long list of every plugin's dependencies in the main module.
=
martin

On Mon, Sep 21, 2015 at 11:45 PM, Gabriel Scherer <gabriel.scherer@gmail.com> wrote:
A .cma or .cmxa archive does not pack its sub-modules under a comm= on
module name: the module name Puz_plugin that you use does not refer to
anything. Accessing any of the constituent modules directly (eg.
Puz_match.foo) should work -- although it may not go through the .cmxa
but directly refer to the compilation unit.

Note that if "_plugin" is intended to refer to dynamic linking, y= ou
may want to use a .mldylib file instead of .mllib, to be used to
generate a .cmxs file: .cmxa is not suitable for dynamic linking
(while, at the bytecode level, .cma work for both static and dynamic
linking).

On Tue, Sep 22, 2015 at 8:23 AM, Martin DeMello <martindemello@gmail.com> wrote:
> If I have my project set up like this:
>
> .
> =E2=94=9C=E2=94=80=E2=94=80 file.ml
> =E2=94=9C=E2=94=80=E2=94=80 plugins
> =E2=94=82=C2=A0 =C2=A0=E2=94=94=E2=94=80=E2=94=80 puz
> =E2=94=82=C2=A0 =C2=A0 =C2=A0 =C2=A0=E2=94=9C=E2=94=80=E2=94=80 puz_bin.ml=
> =E2=94=82=C2=A0 =C2=A0 =C2=A0 =C2=A0=E2=94=9C=E2=94=80=E2=94=80 puz_match.ml=
> =E2=94=82=C2=A0 =C2=A0 =C2=A0 =C2=A0=E2=94=9C=E2=94=80=E2=94=80 puz.ml
> =E2=94=82=C2=A0 =C2=A0 =C2=A0 =C2=A0=E2=94=9C=E2=94=80=E2=94=80 puz_pl= ugin.mllib
> =E2=94=82=C2=A0 =C2=A0 =C2=A0 =C2=A0=E2=94=9C=E2=94=80=E2=94=80 puz_types.ml=
> =E2=94=82=C2=A0 =C2=A0 =C2=A0 =C2=A0=E2=94=94=E2=94=80=E2=94=80 puz_utils.ml=
> =E2=94=94=E2=94=80=E2=94=80 _tags
>
> $ cat plugins/puz/puz_plugin.mllib
> Puz Puz_bin Puz_match
>
> This works:
>
> $ ocamlbuild -use-ocamlfind plugins/puz/puz_plugin.cmxa
> Finished, 22 targets (3 cached) in 00:00:03.
>
> My _tags file:
> ------------------------------------------------
> $ cat _tags
> true: thread,debug
> true: package(core_kernel)
>
> "plugins/puz": include
>
> <gui.*>: package(labltk)
> <**/puz.*>: package(unix), package(str), package(core_kernel), > package(bitstring), package(mikmatch_pcre)
> <**/*_bin.*>: package(bitstring.syntax), syntax(bitstring)
> <**/*_match.*>: package(mikmatch_pcre), syntax(camlp4o)
> ------------------------------------------------
>
> But I can't figure out how to use this library in my main program.= This is a
> minimal example of what I'm trying to do, not working of course: >
> $ cat = file.ml
> open Core_kernel.Std
>
> let read fname =3D
>=C2=A0 =C2=A0let data =3D In_channel.read_all fname in
>=C2=A0 =C2=A0Puz_plugin.read data
>
> $ ocamlbuild -use-ocamlfind file.native
> + ocamlfind ocamlc -c -g -thread -package core_kernel -I plugins/puz -= o
> file.cmo file.ml
> File "file.ml", line 5, characters 2-17:
> Error: Unbound module Puz_plugin
>
> martin

--001a1143c0f6c04ab705205072df--