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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id F3B5B7F734 for ; Tue, 22 Sep 2015 08:46:26 +0200 (CEST) IronPort-PHdr: 9a23:h5u4fhdcI+5kOtSo0jH1EOWflGMj4u6mDksu8pMizoh2WeGdxc6yYR7h7PlgxGXEQZ/co6odzbGG7+a7CCdZucnJmUtBWaIPfidNsd8RkQ0kDZzNImzAB9muURYHGt9fXkRu5XCxPBsdMs//Y1rPvi/6tmZKSV3BPAZ4bt74BpTVx5zukbvip9uIMk4R3GX1SIgxBSv1hD2ZjtMRj4pmJ/R54TryiVwMRd5rw3h1L0mYhRf265T41pdi9yNNp6BprJYYAu3SNp41Rr1ADTkgL3t9pIiy7UGCHkOz4S47eWwTllJsAhPZpEXxV5L19y/7rfZVyTCHMMiwTLYuWD3k4b09GzHyjyJSEjcj7GDRwuB9qa9fpBXp8xl22ZLVZo2YMfd6eqT1ctYTRG4HVcFUAX8SSrigZpcCWrJSdd1TqJPw8h5X9UOz Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=martindemello@gmail.com; spf=Pass smtp.mailfrom=martindemello@gmail.com; spf=None smtp.helo=postmaster@mail-vk0-f48.google.com Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of martindemello@gmail.com) identity=pra; client-ip=209.85.213.48; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="martindemello@gmail.com"; x-sender="martindemello@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of martindemello@gmail.com designates 209.85.213.48 as permitted sender) identity=mailfrom; client-ip=209.85.213.48; receiver=mail3-smtp-sop.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 (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-vk0-f48.google.com) identity=helo; client-ip=209.85.213.48; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="martindemello@gmail.com"; x-sender="postmaster@mail-vk0-f48.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0DQAQCB+ABWnDDVVdFdg0M1aQatAYQ1gwiLGYV3AoEzBzwQAQEBAQEBAQEQAQEBAQEGDQkJIS6CHYIIAQEDARIRBBkBGx4DAQsGAwILNwICIQEBEQEFARwGEwgah3YBAwoIDZlNj0aBMD4xi0aBbIJ5ihIKGScNVoQQAQEBBwEBAQEYAQUOhmWEfYJQgkSCaYFDBYc0hj6Hc4URhgmBb4FNRocQijoFg06CIRIjgRcRJ4Ivgh0eM4ltAQEB X-IPAS-Result: A0DQAQCB+ABWnDDVVdFdg0M1aQatAYQ1gwiLGYV3AoEzBzwQAQEBAQEBAQEQAQEBAQEGDQkJIS6CHYIIAQEDARIRBBkBGx4DAQsGAwILNwICIQEBEQEFARwGEwgah3YBAwoIDZlNj0aBMD4xi0aBbIJ5ihIKGScNVoQQAQEBBwEBAQEYAQUOhmWEfYJQgkSCaYFDBYc0hj6Hc4URhgmBb4FNRocQijoFg06CIRIjgRcRJ4Ivgh0eM4ltAQEB X-IronPort-AV: E=Sophos;i="5.17,571,1437429600"; d="scan'208";a="148157792" Received: from mail-vk0-f48.google.com ([209.85.213.48]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 22 Sep 2015 08:46:25 +0200 Received: by vkgd64 with SMTP id d64so384934vkg.0 for ; Mon, 21 Sep 2015 23:46:24 -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 :content-type; bh=TFthpCnapK6bpZoDp3Qxe1D3IIl2xhTw5xbyhoiKwuo=; b=dKddeMLAL3+hk/nMbpnOqA7CjgOxNvhSRWnC/zuaDG1A4PgYPq80qiaaXX9FKso4XA DyjaGbObW0Ihj3x+vQdt08UfWtQs6ptVsgt2ejAI2JN+Dh4eFunUlXr8exiSg2/V8OsQ bxPi297qw6sCGSgpD5FFgAAOt4hGaoj1Axj2zipMt47K/jLgPD8jIAZe5opJ+ZjzAt6n gniA4wpmlwLC5fesYFP04NFDMKkHTglnaLl0kHTvgbeX8mdOqgRg4OdTNkFAxZ74u9lg 51SutmDN31gJgg3FODoI2kZXpsMYvyZnx4mcB8ZSqnJPzqF7JEGBFgtTH8Fv9RenwnZL xCUg== MIME-Version: 1.0 X-Received: by 10.31.9.81 with SMTP id 78mr2664624vkj.10.1442904384469; Mon, 21 Sep 2015 23:46:24 -0700 (PDT) Received: by 10.103.51.142 with HTTP; Mon, 21 Sep 2015 23:46:24 -0700 (PDT) In-Reply-To: References: Date: Mon, 21 Sep 2015 23:46:24 -0700 Message-ID: From: Martin DeMello To: OCaml List Content-Type: multipart/alternative; boundary=001a1143c0f647fe1b0520505b1b Subject: Re: [Caml-list] building and using a library in a subdirectory --001a1143c0f647fe1b0520505b1b Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I finally found http://ocaml.org/learn/tutorials/ocamlbuild/Using_internal_libraries.html (which didn't come up earlier because I was searching for "subdirectory"); following that I added a myocamlbuild file: $ cat myocamlbuild.ml open Ocamlbuild_plugin let () =3D dispatch begin function | After_rules -> ocaml_lib "plugins/puz/Puz_plugin"; | _ -> () end but then attempting to add to the _tags file: : use_puz_plugin gave me the following: Warning: the tag "use_puz_plugin" is not used in any flag or dependency declaration, so it will have no effect; it may be a typo. Otherwise you can use `mark_tag_used` in your myocamlbuild.ml to disable this warning. + 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 Feedback on the tutorial: It would be useful to have a complete repository corresponding to each of the examples, that could be checked out and played with. martin On Mon, Sep 21, 2015 at 11:23 PM, 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 > --001a1143c0f647fe1b0520505b1b Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
I finally found=C2=A0http://ocaml.org/learn/tut= orials/ocamlbuild/Using_internal_libraries.html (which didn't come = up earlier because I was searching for "subdirectory"); following= that I added a myocamlbuild file:

=C2=A0$ cat myocamlbuild.ml=C2=A0
open Ocamlb= uild_plugin

let () =3D
=C2=A0 dispatch b= egin function
=C2=A0 | After_rules ->
=C2=A0 =C2=A0 = =C2=A0ocaml_lib "plugins/puz/Puz_plugin";
=C2=A0 | _ -&= gt; ()
=C2=A0 end

but then attempting to= add to the _tags file:

<file.*>: use_p= uz_plugin

gave me the following:
<= br>
Warning: the tag "use_puz_plugin" is not used = in any flag or dependency declaration, so it will have no effect; it may be= a typo. Otherwise you can use `mark_tag_used` in your myocamlbuild.ml to disable this warning.
+ oca= mlfind ocamlc -c -g -thread -package core_kernel -I plugins/puz -o file.cmo= file.ml
File "file.ml", line 5, characters 2-17:
Error: U= nbound module Puz_plugin


Feed= back on the tutorial: It would be useful to have a complete repository corr= esponding to each of the examples, that could be checked out and played wit= h.

martin



On Mon, Sep 21, = 2015 at 11:23 PM, 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 =E2= =94=94=E2=94=80=E2=94=80 puz
=E2=94=82 =C2=A0 =C2=A0 =C2=A0 =E2= =94=9C=E2=94=80=E2=94=80 pu= z_bin.ml
=E2=94=82 =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 =E2=94=9C=E2=94=80=E2=94=80 puz.ml
=E2=94=82 =C2=A0 = =C2=A0 =C2=A0 =E2=94=9C=E2=94=80=E2=94=80 puz_plugin.mllib
=E2=94= =82 =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 =E2=94=94=E2=94=80=E2=94=80 puz_utils.ml
=E2=94=94=E2=94=80=E2=94=80 _tags<= /div>

$ cat plugins/puz/puz_plugin.mllib=C2= =A0
Puz Puz_bin Puz_match

This wor= ks:

$ ocamlbuild -use-ocamlfind plugins/puz/p= uz_plugin.cmxa
Finished, 22 targets (3 cached) in 00:00:03.
=

My _tags file:
------------------------= ------------------------
$ cat _tags=C2=A0
true: thread,debug
true: package(core_kernel)

"plugins/puz": include

<gui.*>: package(labltk)
<**/puz.*>: pack= age(unix), package(str), package(core_kernel), package(bitstring), package(= mikmatch_pcre)
<**/*_bin.*>: package(bitstring.syntax), syntax(bitstring)
<**/*_match.*>: p= ackage(mikmatch_pcre), syntax(camlp4o)
-------------= -----------------------------------

But I can&= #39;t figure out how to use this library in my main program. This is a mini= mal example of what I'm trying to do, not working of course:
=
$ cat file= .ml=C2=A0
open Core_kernel.Std

let r= ead fname =3D
=C2=A0 let data =3D In_channel.read_all fname in
=C2=A0 Puz_plugin.read data

$ o= camlbuild -use-ocamlfind file.native
+ ocamlfind ocamlc -c -g -th= read -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

--001a1143c0f647fe1b0520505b1b--