From: Martin DeMello <martindemello@gmail.com>
To: Gabriel Scherer <gabriel.scherer@gmail.com>
Cc: OCaml List <caml-list@yquem.inria.fr>
Subject: Re: [Caml-list] building and using a library in a subdirectory
Date: Mon, 21 Sep 2015 23:52:58 -0700 [thread overview]
Message-ID: <CAFrFfuGH0GY_0_6x75L+MoCC9bBBSwXNzqJWMP+NGJPpWG1K_g@mail.gmail.com> (raw)
In-Reply-To: <CAPFanBGoSC-EptQqKRPGTB2h4O=z3jidjTAYKBT624Y5cmA5aA@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 3424 bytes --]
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 <gabriel.scherer@gmail.com
> 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 <martindemello@gmail.com>
> wrote:
> > If I have my project set up like this:
> >
> > .
> > ├── file.ml
> > ├── plugins
> > │ └── puz
> > │ ├── puz_bin.ml
> > │ ├── puz_match.ml
> > │ ├── puz.ml
> > │ ├── puz_plugin.mllib
> > │ ├── puz_types.ml
> > │ └── puz_utils.ml
> > └── _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 =
> > let data = 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
>
[-- Attachment #2: Type: text/html, Size: 4952 bytes --]
next prev parent reply other threads:[~2015-09-22 6:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-22 6:23 Martin DeMello
2015-09-22 6:45 ` Gabriel Scherer
2015-09-22 6:52 ` Martin DeMello [this message]
2015-09-22 6:58 ` Gabriel Scherer
2015-09-22 7:09 ` Martin DeMello
2015-09-22 7:45 ` Gabriel Scherer
2015-09-22 19:02 ` Martin DeMello
2015-09-22 19:22 ` Christian Lindig
2015-09-22 6:46 ` Martin DeMello
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAFrFfuGH0GY_0_6x75L+MoCC9bBBSwXNzqJWMP+NGJPpWG1K_g@mail.gmail.com \
--to=martindemello@gmail.com \
--cc=caml-list@yquem.inria.fr \
--cc=gabriel.scherer@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox