# Cannot compile sample file with corebuild installed with asdf

**URL:** <https://discuss.ocaml.org/t/cannot-compile-sample-file-with-corebuild-installed-with-asdf/1652>\
**Category:** Learning\
**Tags:** core, build\
**Created:** [March 3, 2018, 11:19am UTC](https://discuss.ocaml.org/t/cannot-compile-sample-file-with-corebuild-installed-with-asdf/1652 "2018-03-03T11:19:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lakret](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/lakret/32/866_2.png) [@lakret](https://discuss.ocaml.org/u/lakret)\
**Post date:** [March 3, 2018, 11:19am UTC](https://discuss.ocaml.org/t/cannot-compile-sample-file-with-corebuild-installed-with-asdf/1652/1 "2018-03-03T11:19:30Z")

</div>

I’m (re)-learning OCaml, and I hit a snag while trying to compile a simple program:

```auto
open Core

let print_current_dir_files () = 
  Sys.readdir "."
  |> Array.to_list
  |> String.concat ~sep:"\n\t"
  |> printf "Files: \n\t%s\n"

let () =
  print_current_dir_files()

```

This code works in `coretop`, but when I try to compile it, that’s what I get:

```auto
$ corebuild src/hello_world.native

+ ocamlfind ocamlopt -linkpkg -g -thread -package base -package core_kernel -package core -I src src/hello_world.cmx -o src/hello_world.native
File "_none_", line 1:
Error: No implementations provided for the following modules:
         Core_kernel__ referenced from src/hello_world.cmx
         Core__ referenced from src/hello_world.cmx
Command exited with code 2.
Compilation unsuccessful after building 4 targets (0 cached) in 00:00:00.

```

I tried adding `-pkg` flags, creating `_tags`, running it with manual linking via `ocamlbuild`, but nothing works.

I have Merlin and utop working without problem with Core. OCaml 4.06.1 is installed with asdf OCaml plugin. Some more debug output:

```auto
$ ocamlfind query core
/home/lakret/.asdf/installs/ocaml/4.06.1/4.06.1/lib/core

$ ocamlfind query core_kernel
/home/lakret/.asdf/installs/ocaml/4.06.1/4.06.1/lib/core_kernel

```

Compiling sample files without Core dependency is working fine.

Any ideas? Maybe I’m missing something?

---

<div class="post-metadata">

**Author:** ![BikalGurung](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/bikalgurung/32/5105_2.png) [@BikalGurung](https://discuss.ocaml.org/u/BikalGurung)\
**Post date:** [March 3, 2018, 1:15pm UTC](https://discuss.ocaml.org/t/cannot-compile-sample-file-with-corebuild-installed-with-asdf/1652/2 "2018-03-03T13:15:22Z")

</div>

I think dune(formerly jbuilder) is by far the best build tool for ocaml these days. [https://github.com/ocaml/dune](https://github.com/ocaml/dune). For your sample file you can follow these steps:

1. Create a jbuild file.

```auto
$cat jbuild
(jbuild_version 1)

(executable
 ((name hello)
  (libraries (core))))

```

1. Build with jbuilder - `jbuilder build hello.exe`
2. Execute - `jbuilder exec -- ./hello.exe`  
prints the following in my temp dir

```auto
Files: 
	hello.ml
	jbuild
	_build
	.merlin

```

---

<div class="post-metadata">

**Author:** ![mseri](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/mseri/32/91_2.png) [@mseri](https://discuss.ocaml.org/u/mseri)\
**Post date:** [March 3, 2018, 5:41pm UTC](https://discuss.ocaml.org/t/cannot-compile-sample-file-with-corebuild-installed-with-asdf/1652/3 "2018-03-03T17:41:18Z")

</div>

I think it is related to this issue (suggested solutions in the linked comment): [ANN: dune (jbuilder) 1.0+beta18](https://discuss.ocaml.org/t/ann-dune-jbuilder-1-0-beta18/1635/3)
