# Ocamlfind, trying to understand which files to install

**URL:** <https://discuss.ocaml.org/t/ocamlfind-trying-to-understand-which-files-to-install/2569>\
**Category:** Learning\
**Tags:** ocamlfind\
**Created:** [September 17, 2018, 5:37pm UTC](https://discuss.ocaml.org/t/ocamlfind-trying-to-understand-which-files-to-install/2569 "2018-09-17T17:37:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![thomas\_ridge](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/thomas_ridge/32/1478_2.png) [@thomas\_ridge](https://discuss.ocaml.org/u/thomas_ridge)\
**Post date:** [September 17, 2018, 5:37pm UTC](https://discuss.ocaml.org/t/ocamlfind-trying-to-understand-which-files-to-install/2569/1 "2018-09-17T17:37:31Z")

</div>

When I `ocamlfind install` some files, I am always a bit unsure which files I should install.

For example, I believe that the .cmxa file should already contain the associated cmx files. So I try to avoid installing the cmx. But then subsequent compilation (eg when building a native executable that uses the library) fails to find a .cmx file. If I install the .cmxa and all the .cmx, everything is fine. But then, doesn’t the cmxa include the cmx? Why do I need the cmxa and the cmx?

---

<div class="post-metadata">

**Author:** ![lindig](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/lindig/32/532_2.png) [@lindig](https://discuss.ocaml.org/u/lindig)\
**Post date:** [September 17, 2018, 5:53pm UTC](https://discuss.ocaml.org/t/ocamlfind-trying-to-understand-which-files-to-install/2569/2 "2018-09-17T17:53:58Z")

</div>

I don’t have an answer but there is this [comment in the compiler source](https://github.com/ocaml/ocaml/blob/b1ee013a6ae4b675f0c6e1a8114e25a15bd649fd/asmcomp/asmlibrarian.ml#L42-L45):

> There is no need to keep the approximation in the .cmxa file,  
> since the compiler will go looking directly for .cmx files.  
> The linker, which is the only one that reads .cmxa files, does not  
> need the approximation.

So it seems the compiler will during compilation of a module look for .cmx files of the dependencies and only during a later linking step the linker will consult the .cmxa.

---

<div class="post-metadata">

**Author:** ![Leonidas](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/leonidas/32/4039_2.png) [@Leonidas](https://discuss.ocaml.org/u/Leonidas)\
**Post date:** [September 18, 2018, 8:55am UTC](https://discuss.ocaml.org/t/ocamlfind-trying-to-understand-which-files-to-install/2569/3 "2018-09-18T08:55:57Z")

</div>

Truth be told, I would not go around and installing things manually — personally I really don’t enjoy working with projects that decided to do a reinvention of a build system which then ends up missing things or installing things in odd places. I would recommend you to use an existing system which will compile code with sensible flags and also install all required files in the right locations.

---

<div class="post-metadata">

**Author:** ![emillon](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/emillon/32/1206_2.png) [@emillon](https://discuss.ocaml.org/u/emillon)\
**Post date:** [September 18, 2018, 9:02am UTC](https://discuss.ocaml.org/t/ocamlfind-trying-to-understand-which-files-to-install/2569/4 "2018-09-18T09:02:51Z")

</div>

Yes. Invoking `ocamlfind` directly used to be the norm a few years ago, but today this is a smell. I’d recommend using `dune` if possible, or if you’re using `ocamlbuild`, you can use `topkg` to manage the installation part.
