caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: David Allsopp <dra-news@metastack.com>
To: "Mr. Herr" <misterherr@freenet.de>,
	"caml-list@inria.fr" <caml-list@inria.fr>
Subject: RE: [Caml-list] ocamlfind? how to compile
Date: Fri, 12 Apr 2013 16:19:57 +0000	[thread overview]
Message-ID: <E51C5B015DBD1348A1D85763337FB6D9CC5ACBC3@Remus.metastack.local> (raw)
In-Reply-To: <51682FE2.60607@freenet.de>

Mr. Herr wrote:
> I did not understand how the helpers for compilation are supposed to work.
> 
> For example I have a script that executes external programs, and needs the
> Unix module.
> 
> For script execution I have in the top of my script: #load "unix.cma";;

Good "trick" for findlib is to add:
	#use "topfind"
to ~/.ocamlinit (create it, if necessary) and then in future toploops you just say
	#require "unix";;
instead. Useful when you start using packages which depend on other packages...

> This must be removed for ocamlc or ocamlopt to work, right? Annoying.

Yes and no - a way around it is to create a wrapper script for debugging in the toploop which loads all the required libraries (or just have libraries you usually need loaded via .ocamlinit). I think it's fairly unusual that you have something that's actively intended for both the toploop *and* separate compilation so it's usually just a matter of making debugging easier in the toploop with a little script.

> But how do I compile it without manually inserting "unix.cma"/"unix.cmxa"
> into the command line? I thought the tools would do it.
> 
> This is what I tried:
> 
> strl@suse122-intel:~/Ocaml> ocamlfind ocamlc -o ml/unix2_exec
> ml/unix2_exec.ml
> ocamlfind: [WARNING] The DLL dllpcre_stubs.so occurs in multiple
> directories:
> /usr/lib64/ocaml/site-lib/pcre
> ocamlfind: [WARNING] The DLL dllpcre_stubs.so occurs in multiple
> directories:
> /usr/lib64/ocaml/stublibs

These warnings look like your package manager is installing redundant files, but that won't be breaking anything.

> File "ml/unix2_exec.ml", line 1:
> Error: Error while linking ml/unix2_exec.cmo:
> Reference to undefined global `Unix'

ocamlfind ocamlc -o ml/unix2_exec -package unix -linkpkg ml/unix2_exec.ml

I have a feeling you may run into interesting issues compiling outside of the working directory, though, but I might be misremembering something...

If you add -verbose to any ocamlfind command then it will show you all the commands it's executing (which allows you to work out error messages from the compilers).

ocamlc command line is documented in Chapter 8 of the manual: http://caml.inria.fr/pub/docs/manual-ocaml-4.00/manual022.html
findlib docs for compiling and linking with packages: http://projects.camlcity.org/projects/dl/findlib-1.3.3/doc/guide-html/x115.html

HTH,


David

  reply	other threads:[~2013-04-12 16:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-11 21:59 [Caml-list] [ANN] Merlin 1.0 released Frédéric Bour
2013-04-12  1:14 ` Francois Berenger
2013-04-13 16:57   ` Frédéric Bour
2013-04-12 16:01 ` [Caml-list] ocamlfind? how to compile Mr. Herr
2013-04-12 16:19   ` David Allsopp [this message]
2013-04-12 17:09     ` Mr. Herr
2013-04-12 18:17       ` David Allsopp
2013-04-12 18:51         ` Mr. Herr
2013-04-12 19:35     ` Mr. Herr
2013-04-14  9:31       ` AW: " Gerd Stolpmann

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=E51C5B015DBD1348A1D85763337FB6D9CC5ACBC3@Remus.metastack.local \
    --to=dra-news@metastack.com \
    --cc=caml-list@inria.fr \
    --cc=misterherr@freenet.de \
    /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;
as well as URLs for NNTP newsgroup(s).