Compiled file doesn't output anything

I have used this installer to get ocaml on my pc https://fdopen.github.io/opam-repository-mingw/installation/

I compiled a .ml file using ocamlopt from the cygwin shell, the compiled file is an exe that I run from the windows cmd. The problem is my program (https://pastebin.com/rsLEK94p it’s a simple interpreter that I copied from a pdf my teacher gave me) should output the result of “eval e;;” but on my cmd there is absolutely nothing (I know the program is ok because I tested it on an online ocaml interpreter).
On the other hand if I compile " print_string “Hello world!\n” ;;" I get hello world on my cmd just fine

You are not printing the result of eval e, only computing and then discarding it. If you want to print the result of e, you need to write a printer (or generate one with a ppx) and then use it to print the result of eval e.

2 Likes

I see I’m still ignorant in ocaml. When I write “let x = 5;;” directly in the interpreter I get “val x : int = 5”, is there any way to get the same effect by writing it in a file and opening the file instead of having to type it manually?

If your editor of choice cannot eval code in the REPL, you can use #use "path/to/file.ml";; in the interactive repl to read the file path/to/file.ml as if you had written its contents.

(Typo, I think. Double quote should be pound sign: #use "path/to/file.ml";;)

You are right, I fixed the typo; thanks.