flori10
flori10

Reputation: 502

OCaml with MSYS2 on Windows: Unbound module stdlib

I have just installed ocaml on MSYS2 with the command

pacman -S mingw-w64-x86_64-ocaml

Then running

ocaml -version

gives me the output 4.14.0

I wrote my first program, which looks like

//bonjour.ml

print_string "Bonjour Florian!";

When I save it and compile it with the command

ocaml -o bonjour.exe bonjour.ml

the error message is

File "command line", line 1:
Error: Unbound module Stdlib

What can I do about this problem? I would really like to work with an installation of ocaml with MSYS2.

Update: I found these instructions https://gist.github.com/mnxn/93009346c1bd56f387daf28413152179 that describe how to install opam with MSYS2.

I can execute all the commands up to point 6 When I then run

bash opam64/install.sh

I get the error message

warning: git not installed. opam will not work without it!
warning: unzip not installed. opam will not work without it!
warning: rsync not installed. opam will not work without it!
warning: patch not installed. opam will not work without it!
warning: diffutils not installed. opam will not work without it!
warning: make not installed. opam will not work without it!
warning: m4 not installed. opam will not work without it!
warning: neither curl nor wget are installed!
pleas install at least on of them
please install either mingw64-i686-gcc-core (32-bit) or mingw64-x86_64-gcc-core (64-bit)
you need a working C compiler to compile native ocaml programs
the following programs are not installed properly:
 tar / xz
I can't proceed :(

However, if just installed git previously with "pacman -Sy git" and then if I run

git --version

it gives me "git version 2.43.2"

I can even look at the script opam64/install.sh

The code that is executed there is this one:

if [ ! -x /usr/bin/cygcheck ] ; then
    echo "warning: your cygwin installation is probably corrupted" >&2
else
    xtmpf="$(mktemp)"
    trap "rm -f \"${xtmpf}\"" EXIT
    /usr/bin/cygcheck -dc >"${xtmpf}"
    for f in git unzip rsync patch diffutils make m4 ; do
        if ! grep -q "^${f} " "$xtmpf" ; then
            echo "warning: ${f} not installed. opam will not work without it!" >&2
        fi
    done
    if ! /usr/bin/grep -q "^curl " "$xtmpf" ; then
        if ! /usr/bin/grep -q "^wget " "$xtmpf" ; then
            echo "warning: neither curl nor wget are installed!" >&2
            echo "pleas install at least on of them" >&2
        fi
    fi
    if ! /usr/bin/grep -q "^mingw64-i686-gcc-core" "$xtmpf" ; then
        if ! /usr/bin/grep -q "^mingw64-x86_64-gcc-core " "$xtmpf" ; then
            echo "please install either mingw64-i686-gcc-core (32-bit) or mingw64-x86_64-gcc-core (64-bit)" >&2
            echo "you need a working C compiler to compile native ocaml programs" >&2
        fi
    fi
fi

Upvotes: 0

Views: 174

Answers (0)

Related Questions