# \[Dream\] my first try

**URL:** <https://discuss.ocaml.org/t/dream-my-first-try/15773>\
**Category:** Learning\
**Tags:** dream\
**Created:** [December 9, 2024, 10:07pm UTC](https://discuss.ocaml.org/t/dream-my-first-try/15773 "2024-12-09T22:07:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![NAlec](https://avatars.discourse-cdn.com/v4/letter/n/91b2a8/32.png) [@NAlec](https://discuss.ocaml.org/u/NAlec)\
**Post date:** [December 9, 2024, 10:07pm UTC](https://discuss.ocaml.org/t/dream-my-first-try/15773/1 "2024-12-09T22:07:33Z")

</div>

I am willing to test the Dream webframework for a small project.

Installing it took me some time because of the recent ssl dependency issue. Then I am trying to reproduce the 01-hello tutorial by copy/paste the source code in a project I build myself. I have a linking error I don’t know how to resolve (@antron ). Help appreciated.

My ocaml setup is on a windows box.

```auto
opam exec -- dune init project test_dream

```

I modify the dune file:

```auto
(executable
 (public_name test_dream)
 (name main)
 (libraries test_dream dream))

```

copy / paste the source code into main.ml

```auto
let () =
  Dream.run (fun _ ->
    Dream.html "Good morning, world!")

```

and build

```auto
PS H:\OCaml\test_dream> (& opam env) -split '\r?\n' | ForEach-Object { Invoke-Expression $_ }
PS H:\OCaml\test_dream> opam exec -- dune build                  
File "bin/dune", line 3, characters 7-11:
3 | (name main)
           ^^^^
/bin/bash: C:UsersNAlec~1AppDataLocalTempbuild_967b29_dunelongcmd8d30f6: No folder or file of this type
** Fatal error: Error during linking

File "caml_startup", line 1:
Error: Error during linking (exit code 2)
PS H:\OCaml\test_dream> 

```

If it were necessary :

```auto
PS H:\OCaml\test_dream> opam show dream

<><> dream: information on all versions <><><><><><><><><><><><><><><><><><> 🐫 
name dream
all-installed-versions 1.0.0~alpha7 [default]
all-versions 1.0.0~alpha1 1.0.0~alpha2 1.0.0~alpha3 1.0.0~alpha4 1.0.0~alpha5 1.0.0~alpha6 1.0.0~alpha7

<><> Version-specific details <><><><><><><><><><><><><><><><><><><><><><><> 🐫 
version 1.0.0~alpha7
repository default
url.src "https://github.com/aantron/dream/releases/download/1.0.0-alpha7/dream-1.0.0-alpha7.tar.gz"
url.checksum "sha256=b715cecf7e2b249335c8d1cd22c3e87017e40c0556774d209f338f9d78388c86"
homepage "https://github.com/aantron/dream"
doc "https://aantron.github.io/dream"
bug-reports "https://github.com/aantron/dream/issues"
dev-repo "git+https://github.com/aantron/dream.git"
authors "Anton Bachin <antonbachin@yahoo.com>"
maintainer "Anton Bachin <antonbachin@yahoo.com>"
license "MIT"
tags "http" "web" "framework" "websocket" "graphql" "server" "http2" "tls"
depends "base-unix"
             "bigarray-compat"
             "camlp-streams"
             "caqti" {>= "2.0.0"}
             "caqti-lwt" {>= "2.0.0"}
             ("conf-libev" {os != "win32"} | "ocaml" {os = "win32"})
             "cstruct" {>= "6.0.0"}
             "digestif" {>= "0.7"}
             "dream-httpaf" {>= "1.0.0~alpha3"}
             "dream-pure" {>= "1.0.0~alpha2"}
             "dune" {>= "2.7.0"}
             "fmt" {>= "0.8.7"}
             "graphql_parser"
             "graphql-lwt"
             "lambdasoup" {>= "0.6.1"}
             "lwt"
             "lwt_ppx" {>= "1.2.2"}
             "lwt_ssl"
             "logs" {>= "0.5.0"}
             "magic-mime"
             "markup" {>= "1.0.2"}
             "mirage-clock" {>= "3.0.0"}
             "mirage-crypto" {>= "1.0.0"}
             "mirage-crypto-rng" {>= "1.0.0"}
             "mirage-crypto-rng-lwt"
             "multipart_form" {>= "0.4.0"}
             "multipart_form-lwt"
             "ocaml" {>= "4.08.0"}
             "ptime" {>= "0.8.1"}
             "ssl" {>= "0.5.8"}
             "uri" {>= "4.2.0"}
             "yojson"
             "alcotest" {with-test}
             "bisect_ppx" {with-test & >= "2.5.0"}
             "caqti-driver-postgresql" {with-test}
             "caqti-driver-sqlite3" {with-test}
             "crunch" {with-test}
             "html_of_jsx" {with-test}
             "js_of_ocaml" {with-test}
             "js_of_ocaml-ppx" {with-test}
             "ppx_expect" {with-test & >= "v0.15.0"}
             "ppx_yojson_conv" {with-test}
             "reason" {with-test}
             "tyxml" {with-test & >= "4.5.0"}
             "tyxml-jsx" {with-test}

```

---

<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:** [December 9, 2024, 10:43pm UTC](https://discuss.ocaml.org/t/dream-my-first-try/15773/2 "2024-12-09T22:43:37Z")

</div>

> [@NAlec](#):
>
> ` (libraries test_dream dream))`

`test_dream` is not needed here. It’s the name of your project and the public name of your executable. The `libraries` field lists the _dependency_ libraries. Your executable is not depending on itself.

Try copying and running _exactly_ the 1-hello example as shown in the Dream repo: [dream/example/1-hello at master · aantron/dream · GitHub](https://github.com/aantron/dream/tree/master/example/1-hello)

It is designed to be a complete, self-contained project. You don’t need to initialize a new project with `dune init project`. Just try running the project in the above directory. Follow the instructions in the readme shown in my link.

---

<div class="post-metadata">

**Author:** ![NAlec](https://avatars.discourse-cdn.com/v4/letter/n/91b2a8/32.png) [@NAlec](https://discuss.ocaml.org/u/NAlec)\
**Post date:** [December 10, 2024, 10:07pm UTC](https://discuss.ocaml.org/t/dream-my-first-try/15773/3 "2024-12-10T22:07:45Z")

</div>

I have copied the exact 1-hello example and build it with the same error.

The `test_dream` in the `libraries` is added by dune at initialisation of projects and I don’t think this is the issue.

```auto
PS H:\OCaml\test_dream> opam exec -- dune build
File "dune", line 2, characters 7-12:
2 | (name hello)
           ^^^^^
/bin/bash: C:UsersNAlecAppDataLocalTempbuild_71f7d1_dunelongcmd9f3bd8: Aucun fichier ou dossier de ce type
** Fatal error: Error during linking

File "caml_startup", line 1:
Error: Error during linking (exit code 2)
PS H:\OCaml\test_dream> 

```

---

<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:** [December 10, 2024, 11:06pm UTC](https://discuss.ocaml.org/t/dream-my-first-try/15773/4 "2024-12-10T23:06:57Z")

</div>

> [@NAlec](#):
>
> `C:UsersNAlecAppDataLocalTempbuild_71f7d1_dunelongcmd9f3bd8: Aucun fichier ou dossier de ce type`

Looks like all the backslash characters have been dropped. Maybe some part of your system is mixing up file paths. I think this is an issue where we would need to know how exactly you installed OCaml/opam, which shell you are using (cmd.exe? PowerShell?), and so on. Looks like the OCaml installation itself has an issue.

---

<div class="post-metadata">

**Author:** ![jaycle](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/jaycle/32/4161_2.png) [@jaycle](https://discuss.ocaml.org/u/jaycle)\
**Post date:** [December 12, 2024, 5:15am UTC](https://discuss.ocaml.org/t/dream-my-first-try/15773/5 "2024-12-12T05:15:08Z")

</div>

You may be experiencing what is covered in [this thread](https://discuss.ocaml.org/t/dunelongcmd-linking-error-on-windows-using-ocamlopt/15469/4).

---

<div class="post-metadata">

**Author:** ![NAlec](https://avatars.discourse-cdn.com/v4/letter/n/91b2a8/32.png) [@NAlec](https://discuss.ocaml.org/u/NAlec)\
**Post date:** [December 13, 2024, 3:21pm UTC](https://discuss.ocaml.org/t/dream-my-first-try/15773/6 "2024-12-13T15:21:38Z")

</div>

Indeed ! Using @b-valdez trick solved the issue for me. I had WSL installed as well.
