# Newbie question: Core and Base

**URL:** <https://discuss.ocaml.org/t/newbie-question-core-and-base/14830>\
**Category:** Learning\
**Created:** [June 21, 2024, 1:13pm UTC](https://discuss.ocaml.org/t/newbie-question-core-and-base/14830 "2024-06-21T13:13:05Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Terry\_Phelps](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/terry_phelps/32/5235_2.png) [@Terry\_Phelps](https://discuss.ocaml.org/u/Terry_Phelps)\
**Post date:** [June 21, 2024, 1:13pm UTC](https://discuss.ocaml.org/t/newbie-question-core-and-base/14830/1 "2024-06-21T13:13:05Z")

</div>

I’ve started to read Real World Ocaml. I installed opam, ocaml 5.2, core, and utop. When I start utop and “open Base” it works. When I start ocaml and “open Base”, it says “Unbound module Base”. I sure didn’t expect to see a difference there. I fear that if ocaml can’t ‘open Base’, ocamlc won’t be able to either, and nothing will compile.

There must be a simple answer. Please tell me what it is.

---

<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:** [June 21, 2024, 1:17pm UTC](https://discuss.ocaml.org/t/newbie-question-core-and-base/14830/2 "2024-06-21T13:17:09Z")

</div>

To make the compiler see the dependency you need to declare that you depend on the findlib package `base` (this goes for all third-party packages, not just `base`).

How to do that depends on the way you build your project.

---

<div class="post-metadata">

**Author:** ![Terry\_Phelps](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/terry_phelps/32/5235_2.png) [@Terry\_Phelps](https://discuss.ocaml.org/u/Terry_Phelps)\
**Post date:** [June 21, 2024, 1:23pm UTC](https://discuss.ocaml.org/t/newbie-question-core-and-base/14830/3 "2024-06-21T13:23:00Z")

</div>

That tells me how to make ocamlc ‘open Base’, I suppose, once I find out how to do dune. But what about opening Base in ocaml interactively? Or should I just not do that, and use utop instead?

---

<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:** [June 21, 2024, 1:26pm UTC](https://discuss.ocaml.org/t/newbie-question-core-and-base/14830/4 "2024-06-21T13:26:18Z")

</div>

If you use `dune utop` it will launch utop with the packages that you depend in your project, otherwise you can also call

```auto
#require "base";;

```

in the Toplevel (or UTop) to load the dependency by hand. `utop` also has a `require` flag that does this automatically.

---

<div class="post-metadata">

**Author:** ![vlaviron](https://avatars.discourse-cdn.com/v4/letter/v/ec9cab/32.png) [@vlaviron](https://discuss.ocaml.org/u/vlaviron)\
**Post date:** [June 21, 2024, 1:39pm UTC](https://discuss.ocaml.org/t/newbie-question-core-and-base/14830/5 "2024-06-21T13:39:51Z")

</div>

Note: `#require` is not a normal directive for `ocaml`. It is only made available if you use some scripts provided by the `findlib` library which is part of `ocamlfind`.  
So from a vanilla `ocaml` prompt, assuming that you have installed the opam package `ocamlfind`, you can do `#use "topfind";;` then `#require "base";;` and after that you can use Base as you wish, for instance through `open Base;;`.

For `ocamlc`, the issue will come up again; the solution is a bit different. You can use `ocamlfind` as your driver for the compilers: `ocamlfind ocamlc -package base -c my_file.ml` for compile-only commands, `ocamlfind ocamlc -package base -linkpkg -o my_exe my_file.cmo` to produce an executable (if you replace `my_file.cmo` with `my_file.ml` in the last command you can compile and link at the same time).

---

<div class="post-metadata">

**Author:** ![Terry\_Phelps](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/terry_phelps/32/5235_2.png) [@Terry\_Phelps](https://discuss.ocaml.org/u/Terry_Phelps)\
**Post date:** [June 21, 2024, 1:43pm UTC](https://discuss.ocaml.org/t/newbie-question-core-and-base/14830/6 "2024-06-21T13:43:34Z")

</div>

Ah, thank you very much. I understand what to do, I think.

---

<div class="post-metadata">

**Author:** ![Kakadu](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/kakadu/32/1204_2.png) [@Kakadu](https://discuss.ocaml.org/u/Kakadu)\
**Post date:** [June 21, 2024, 7:14pm UTC](https://discuss.ocaml.org/t/newbie-question-core-and-base/14830/7 "2024-06-21T19:14:56Z")

</div>

Should we add instructions how to use vanilla toplevel to [Installing OCaml · OCaml Documentation](https://ocaml.org/docs/installing-ocaml) ?

---

<div class="post-metadata">

**Author:** ![yawaramin](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/yawaramin/32/3384_2.png) [@yawaramin](https://discuss.ocaml.org/u/yawaramin)\
**Post date:** [June 21, 2024, 8:46pm UTC](https://discuss.ocaml.org/t/newbie-question-core-and-base/14830/8 "2024-06-21T20:46:25Z")

</div>

As a beginner, there’s no reason for you to be using vanilla `ocaml` as your REPL. Just use utop. It’s the documented and recommended path.

As for compiling with Core and Base in projects, same story. Follow the documentation and use dune, which will take care of these details for you.

Don’t borrow trouble you don’t need 😉

---

<div class="post-metadata">

**Author:** ![hyphenrf](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/hyphenrf/32/2733_2.png) [@hyphenrf](https://discuss.ocaml.org/u/hyphenrf)\
**Post date:** [July 3, 2024, 12:05pm UTC](https://discuss.ocaml.org/t/newbie-question-core-and-base/14830/9 "2024-07-03T12:05:00Z")

</div>

If I were OP, I’d take this advice to its full extent and follow the [Learn OCaml](https://ocaml.org/docs) docs in that they correctly label RWO as an intermediate book, not for beginners 😁

---

<div class="post-metadata">

**Author:** ![Redglyph](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/redglyph/32/6118_2.png) [@Redglyph](https://discuss.ocaml.org/u/Redglyph)\
**Post date:** [August 9, 2025, 12:28pm UTC](https://discuss.ocaml.org/t/newbie-question-core-and-base/14830/10 "2025-08-09T12:28:40Z")

</div>

For information, I had the same problem in `utop`, too, after a fresh installation and not yet in a project/workspace.

Typing `#require “base”;;` as suggested by @Leonidas solved the problem. Thanks!
