I am learning more complex compilations in OCaml
.
first I haven't been a C programmer and I really don't know what is make
, etc. I am using Mac OS X terminal
and i am also a Java programmer.
I find that in OCaml, there some things like ocamlc
, ocamlbuild
, ocamlfind
, oasis
, etc. I got very confused by them.
Question 1
Can anyone tell me which one I should use among ocamlc
, ocamlbuild
, ocamlfind
, oasis
?
Question 2
I tried this tutorial http://nicolaspouillard.fr/ocamlbuild/ocamlbuild-user-guide.html, it is good for ocamlbuild
.
But if I want to use external libraries such as ocaml-batteries
or camomile
, how can I link those libraries using ocamlbuild
?
Question 3
This is a more practical question about all the external libraries.
So for many ocaml libraries, I use opam install
to install them.
why need to install a library? I mean, in Java, normally we just copy a lib to somewhere and then include the path of the lib into -classpath
or -cp
. then why we need to install a OCaml library?
after opam install
a lib, such as camomile
(for utf8), what happened and what will happen? Is this kind of install just download sourcefiles of a lib and copy it to somewhere?
how can find the library then? for example, if I opam install camomile
, then how can I link or use them in my own code?
normally how to use a ocaml library
? for example, for camomile
(http://camomile.sourceforge.net/dochtml/index.html) they have three modules: CamomileLibrary
, etc. So I should open
the module in my code, right?
Tools:
With a recent ocamlbuild you can use 'ocamlbuild -use-ocamlfind -pkg -pkg ... ' as quick way of building your project with ocamlfind packages package1, package2. A next step would be to use 'ocamlbuild -use-ocamlfind ' and put package() directives in a _tags file.
However I would recommend trying oasis, it simplifies creating a build system for your project. If you want to see what happens "under-the-hood" when using oasis or ocamlbuild see the _build/_log file. It contains all the ocamlfind/ocamlc/ocamldep/ocamlopt invocations.
The opam question probably belongs into a separate question.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With