Building and Debugging a Simple Ocaml Program

Hi all,
I am trying to build a basic program using the Ocaml language. However, I don’t know how to proceed with building and debugging it. Could you please suggest a valid document link or GitHub repository code for my reference? I have attached a screenshot of my project to this post.

Thank you in advance,

It sounds like you are a beginner in OCaml. Basic information about building simple projects is available from

There’s also information in

For debugging I’m afraid you will have to get used to printf debugging (as already mentioned in Enhancing Ocaml Debugging Experience in Visual Studio Code - #2 by nojb).

Cheers,
Nicolas

2 Likes

Hi @nojb ,
Thank you for your response.
I ran a simple project called “Hello World” (this reference - Get Up and Running With OCaml · OCaml Tutorials). I followed the commands below:

  1. opam user-setup install
  2. dune init project helloworld
  3. cd helloworld
  4. dune build
  5. dune exec ./bin/main.exe and dune exec helloworld

The result is: “Hello, World!”

It is running, but I would like to know how to debug. Please let me know if debugging is possible using the VS Code extension. (I have installed the VS Code extension and have attached it to this message.) If it is possible, please provide step-by-step instructions.

Thanks in advance!

As already mentioned, your options are:

(This is what I know; perhaps others will have other suggestions.)

Cheers,
Nicolas

Hi @nojb,
Thank you for your response.

In the command line, I am using ‘break’ commands, and they are working (command line: ‘break @filename line-number’). However, these commands are not fully effective. I need to run step by step using any extension in VS Code. Please let me know if there are any options available. Kindly provide a valid reference with a read-me file.

Thanks in advance.