# Creating opam switch version 5.3.0+trunk

**URL:** https://discuss.ocaml.org/t/creating-opam-switch-version-5-3-0-trunk/15121
**Category:** Ecosystem
**Tags:** opam, windows, opam-switch
**Created:** [August 10, 2024, 3:15pm UTC](https://discuss.ocaml.org/t/creating-opam-switch-version-5-3-0-trunk/15121 "2024-08-10T15:15:40Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![pyvovale](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/pyvovale/32/5489_2.png) [@pyvovale](https://discuss.ocaml.org/u/pyvovale)
#### Post date: [August 10, 2024, 3:15pm UTC](https://discuss.ocaml.org/t/creating-opam-switch-version-5-3-0-trunk/15121/1 "2024-08-10T15:15:40Z")

</div>

I installed Ocaml on windows, and now I would like to create a new switch. In powershell I typed the following:

```auto
opam switch create ocaml-variants 5.3.0+trunk --jobs=1

```

Here is the output that I get:

```auto
<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><>
Switch invariant: ["ocaml-variants" {= "5.3.0+trunk"}]
[NOTE] It seems you have not updated your repositories for a while. Consider updating them with:
       opam update

[NOTE] External dependency handling not supported for OS family 'windows'.
       You can disable this check using 'opam option --global depext=false'

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
✶ installed base-bigarray.base
✶ installed base-threads.base
✶ installed base-unix.base
▼ retrieved ocaml-variants.5.3.0+trunk (https://github.com/ocaml/ocaml/archive/trunk.tar.gz)
[ERROR] The compilation of ocaml-variants.5.3.0+trunk failed at "./configure --prefix=C:\\Users\\shuri\\AppData\\Local\\opam\\ocaml-variants
        --docdir=C:\\Users\\shuri\\AppData\\Local\\opam\\ocaml-variants\\doc/ocaml -C --disable-warn-error".

#=== ERROR while compiling ocaml-variants.5.3.0+trunk =========================#
# context 2.2.0~alpha0~20221228-r3 | win32/x86_64 | | git+https://github.com/ocaml/opam-repository.git#6c3f73f42890cc19f81eb1dec8023c2cd7b8b5cd
# path C:\Users\shuri\AppData\Local\opam\ocaml-variants\.opam-switch\build\ocaml-variants.5.3.0+trunk
# command C:\Users\shuri\AppData\Local\opam\ocaml-variants\.opam-switch\build\ocaml-variants.5.3.0+trunk\./configure --prefix=C:\Users\shuri\AppData\Local\opam\ocaml-variants --docdir=C:\Users\shuri\AppData\Local\opam\ocaml-variants\doc/ocaml -C --disable-warn-error
# exit-code 69
# env-file C:\Users\shuri\AppData\Local\opam\log\ocaml-variants-16204-0d7240.env
# output-file C:\Users\shuri\AppData\Local\opam\log\ocaml-variants-16204-0d7240.out
### output ###
# [...]
# checking whether stripping libraries is possible... no
# checking if libtool supports shared libraries... yes
# checking whether to build shared libraries... yes
# checking whether to build static libraries... yes
# checking how to run the C preprocessor... cl.exe -E
# checking C compiler vendor... msvc-1929
# checking whether host executables can be run in the build... yes
# checking whether #! works in shell scripts... yes
# checking whether the C compiler accepts -Wold-style-declaration... no
# checking whether the C compiler accepts -Wimplicit-fallthrough=5... no
# checking whether the C compiler accepts -Wimplicit-fallthrough... no
# configure: error: This version of MSVC is too old. Please use Visual Studio version 17.8 or above.

<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
┌─ The following actions failed
│ λ build ocaml-variants 5.3.0+trunk
└─
┌─ The following changes have been performed (the rest was aborted)
│ ✶ install base-bigarray base
│ ✶ install base-threads base
│ ✶ install base-unix base
└─
# Run eval $(opam env --switch=ocaml-variants) to update the current shell environment
Switch initialisation failed: clean up? ('n' will leave the switch partially installed) [y/n]

```

This is very confusing because I have the latest Visual Studio version. Do you have any idea how to fix it?

---

<div class="post-metadata">

### Author: ![nojb](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/nojb/32/519_2.png) [@nojb](https://discuss.ocaml.org/u/nojb)
#### Post date: [August 11, 2024, 5:10am UTC](https://discuss.ocaml.org/t/creating-opam-switch-version-5-3-0-trunk/15121/2 "2024-08-11T05:10:06Z")

</div>

> [@pyvovale](#):
>
> I have the latest Visual Studio version

Just a wild guess, but maybe you have more than one MSVC version installed? The `./configure` script detected the `cl` compiler, version 1929, which corresponds to Visual Studio 2019.

> checking C compiler vendor… msvc-1929

Cheers,  
Nicolas

---

<div class="post-metadata">

### Author: ![pyvovale](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/pyvovale/32/5489_2.png) [@pyvovale](https://discuss.ocaml.org/u/pyvovale)
#### Post date: [August 11, 2024, 8:24am UTC](https://discuss.ocaml.org/t/creating-opam-switch-version-5-3-0-trunk/15121/3 "2024-08-11T08:24:28Z")

</div>

Hi Nicolas,

That is most definitely the case. Following the [ocaml installation page on windows](https://ocaml.org/install#win), the first command you have to execute is

```auto
winget install Microsoft.VisualStudio.2019.BuildTools --override "--wait --passive --installPath C:\VS --addProductLang En-us --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended"

```

I tried uninstalling the version above, however it causes all the Ocaml tooling to fail. I do not know how to tell my machine : “Hey, I have a newer version of MSVC Build tools, please use that one from now on”

---

<div class="post-metadata">

### Author: ![hhugo](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/hhugo/32/1143_2.png) [@hhugo](https://discuss.ocaml.org/u/hhugo)
#### Post date: [August 11, 2024, 8:38am UTC](https://discuss.ocaml.org/t/creating-opam-switch-version-5-3-0-trunk/15121/4 "2024-08-11T08:38:58Z")

</div>

Try `opam update` first.  
Do you have use opam 2.2 ?  
I’m surprised opam wants to install a msvc port of ocaml.

---

<div class="post-metadata">

### Author: ![pyvovale](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/pyvovale/32/5489_2.png) [@pyvovale](https://discuss.ocaml.org/u/pyvovale)
#### Post date: [August 11, 2024, 8:50am UTC](https://discuss.ocaml.org/t/creating-opam-switch-version-5-3-0-trunk/15121/5 "2024-08-11T08:50:35Z")

</div>

ok, did the update. Here is my opam version : 2.2.0~alpha0~20221228-r3. However, when I try to create the switch I get exactly the same error message as above.

---

<div class="post-metadata">

### Author: ![hhugo](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/hhugo/32/1143_2.png) [@hhugo](https://discuss.ocaml.org/u/hhugo)
#### Post date: [August 11, 2024, 12:13pm UTC](https://discuss.ocaml.org/t/creating-opam-switch-version-5-3-0-trunk/15121/6 "2024-08-11T12:13:36Z")

</div>

Your opam version is too old, try the official release for 2.2 [opam - Platform Blog](https://opam.ocaml.org/blog/opam-2-2-0/)

---

<div class="post-metadata">

### Author: ![pyvovale](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/pyvovale/32/5489_2.png) [@pyvovale](https://discuss.ocaml.org/u/pyvovale)
#### Post date: [August 11, 2024, 12:44pm UTC](https://discuss.ocaml.org/t/creating-opam-switch-version-5-3-0-trunk/15121/7 "2024-08-11T12:44:18Z")

</div>

Thanks! I managed to update the opam version, but the new type of error appeared:

```auto
<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><> 🐫
Switch invariant: ["ocaml-variants" {= "5.3.0+trunk"}]

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><> 🐫
∗ installed base-bigarray.base
∗ installed base-threads.base
∗ installed base-unix.base
⬇ retrieved ocaml-variants.5.3.0+trunk (https://github.com/ocaml/ocaml/archive/trunk.tar.gz)
[ERROR] The compilation of ocaml-variants.5.3.0+trunk failed at "./configure
        --prefix=C:\\Users\\shuri\\AppData\\Local\\opam\\ocaml_53
        --docdir=C:\\Users\\shuri\\AppData\\Local\\opam\\ocaml_53\\doc/ocaml -C --disable-warn-error".

#=== ERROR while compiling ocaml-variants.5.3.0+trunk =========================#
# context 2.2.0 | win32/x86_64 | | git+https://github.com/ocaml/opam-repository.git#6c3f73f42890cc19f81eb1dec8023c2cd7b8b5cd
# path ~\AppData\Local\opam\ocaml_53\.opam-switch\build\ocaml-variants.5.3.0+trunk
# command ~\AppData\Local\opam\ocaml_53\.opam-switch\build\ocaml-variants.5.3.0+trunk\./configure --prefix=C:\Users\shuri\AppData\Local\opam\ocaml_53 --docdir=C:\Users\shuri\AppData\Local\opam\ocaml_53\doc/ocaml -C --disable-warn-error
# exit-code 77
# env-file ~\AppData\Local\opam\log\ocaml-variants-21428-d6864e.env
# output-file ~\AppData\Local\opam\log\ocaml-variants-21428-d6864e.out
### output ###
# [...]
# checking for csc... csc
# configure: WARNING: Mono is not yet supported - C sharp tests disabled
# checking for ld... no
# checking for link... link
# checking how to print strings... printf
# checking for gcc... no
# checking for cc... no
# checking for cl.exe... cl.exe
# checking whether the C compiler works... no
# configure: error: in `/cygdrive/c/Users/shuri/AppData/Local/opam/ocaml_53/.opam-switch/build/ocaml-variants.5.3.0+trunk':
# configure: error: C compiler cannot create executables
# See `config.log' for more details

<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><> 🐫
┌─ The following actions failed
│ λ build ocaml-variants 5.3.0+trunk
└─
┌─ The following changes have been performed (the rest was aborted)
│ ∗ install base-bigarray base
│ ∗ install base-threads base
│ ∗ install base-unix base
└─
# Run (& opam env --switch=ocaml_53) -split '\r?\n' | ForEach-Object { Invoke-Expression $_ } to update the current
shell environment
Switch initialisation failed: clean up? ('n' will leave the switch partially installed) [y/n]

```

Would you kindly help me investigating this error a bit further?

---

<div class="post-metadata">

### Author: ![hhugo](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/hhugo/32/1143_2.png) [@hhugo](https://discuss.ocaml.org/u/hhugo)
#### Post date: [August 12, 2024, 3:24pm UTC](https://discuss.ocaml.org/t/creating-opam-switch-version-5-3-0-trunk/15121/8 "2024-08-12T15:24:27Z")

</div>

It still doesn’t look like your opam repository is up to date.  
Maybe paste the entire output of  
`opam --version` + `opam update` + the opam switch creation

---

<div class="post-metadata">

### Author: ![pyvovale](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/pyvovale/32/5489_2.png) [@pyvovale](https://discuss.ocaml.org/u/pyvovale)
#### Post date: [August 12, 2024, 9:14pm UTC](https://discuss.ocaml.org/t/creating-opam-switch-version-5-3-0-trunk/15121/9 "2024-08-12T21:14:45Z")

</div>

I removed the default switch, and now there is another type of error. Here are some examples of input/output:

input: `opam --version`  
output: 2.2.0  
\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<  
input:

```auto
opam update

```

output:

```auto
<><> Updating package repositories ><><><><><><><><><><><><><><><><><><><><> 🐫
[default] no changes from git+https://github.com/ocaml/opam-repository.git#6c3f73f42890cc19f81eb1dec8023c2cd7b8b5cd

```

\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<  
input:

```auto
opam switch create ocaml_53 5.3.0+trunk

```

output:

```auto
<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><> 🐫
Switch invariant: ["ocaml-variants" {= "5.3.0+trunk"}]

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><> 🐫
[ERROR] Failed to get sources of ocaml-variants.5.3.0+trunk: Download failed
∗ installed base-bigarray.base
∗ installed base-threads.base
∗ installed base-unix.base

#=== ERROR while fetching sources for ocaml-variants.5.3.0+trunk ==============#
OpamSolution.Fetch_fail("https://github.com/ocaml/ocaml/archive/trunk.tar.gz (download failed)")

<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><> 🐫
┌─ The following actions failed
│ ⬇ fetch ocaml-variants 5.3.0+trunk
└─
┌─ The following changes have been performed (the rest was aborted)
│ ∗ install base-bigarray base
│ ∗ install base-threads base
│ ∗ install base-unix base
└─
# Run (& opam env --switch=ocaml_53) -split '\r?\n' | ForEach-Object { Invoke-Expression $_ } to update the current
shell environment
Switch initialisation failed: clean up? ('n' will leave the switch partially installed) [y/n]

```

\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<  
input:

```auto
opam switch create ocaml_511 5.1.1 --jobs=1

```

output:

```auto
<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><> 🐫
Switch invariant: ["ocaml-base-compiler" {= "5.1.1"} | "ocaml-system" {= "5.1.1"}]

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><> 🐫
∗ installed base-bigarray.base
∗ installed base-threads.base
∗ installed base-unix.base
∗ installed ocaml-options-vanilla.1
⬇ retrieved ocaml-base-compiler.5.1.1 (cached)
[ERROR] The compilation of ocaml-base-compiler.5.1.1 failed at "./configure
        --prefix=C:\\Users\\shuri\\AppData\\Local\\opam\\ocaml_511
        --docdir=C:\\Users\\shuri\\AppData\\Local\\opam\\ocaml_511\\doc/ocaml -C".

#=== ERROR while compiling ocaml-base-compiler.5.1.1 ==========================#
# context 2.2.0 | win32/x86_64 | | git+https://github.com/ocaml/opam-repository.git#6c3f73f42890cc19f81eb1dec8023c2cd7b8b5cd
# path ~\AppData\Local\opam\ocaml_511\.opam-switch\build\ocaml-base-compiler.5.1.1
# command ~\AppData\Local\opam\ocaml_511\.opam-switch\build\ocaml-base-compiler.5.1.1\./configure --prefix=C:\Users\shuri\AppData\Local\opam\ocaml_511 --docdir=C:\Users\shuri\AppData\Local\opam\ocaml_511\doc/ocaml -C
# exit-code 1
# env-file ~\AppData\Local\opam\log\ocaml-base-compiler-22688-235621.env
# output-file ~\AppData\Local\opam\log\ocaml-base-compiler-22688-235621.out
### output ###
# [...]
# checking host system type... x86_64-pc-cygwin
# checking target system type... x86_64-pc-cygwin
# checking for ld... no
# checking for link... link
# checking how to print strings... printf
# checking for gcc... no
# checking for cc... no
# checking for cl.exe... no
# checking for clang... no
# configure: error: in `/cygdrive/c/Users/shuri/AppData/Local/opam/ocaml_511/.opam-switch/build/ocaml-base-compiler.5.1.1':
# configure: error: no acceptable C compiler found in $PATH
# See `config.log' for more details

<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><> 🐫
┌─ The following actions failed
│ λ build ocaml-base-compiler 5.1.1
└─
┌─ The following changes have been performed (the rest was aborted)
│ ∗ install base-bigarray base
│ ∗ install base-threads base
│ ∗ install base-unix base
│ ∗ install ocaml-options-vanilla 1
└─
# Run (& opam env --switch=ocaml_511) -split '\r?\n' | ForEach-Object { Invoke-Expression $_ } to update the current
shell environment
Switch initialisation failed: clean up? ('n' will leave the switch partially installed) [y/n]

```

\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<  
input:

```auto
opam switch create 4.14.2

```

output:

```auto
<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><> 🐫
Switch invariant: ["ocaml-base-compiler" {= "4.14.2"} | "ocaml-system" {= "4.14.2"}]

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><> 🐫
∗ installed base-bigarray.base
∗ installed base-threads.base
∗ installed base-unix.base
[ERROR] The compilation of ocaml-system.4.14.2 failed at "ocaml gen_ocaml_config.ml".

#=== ERROR while compiling ocaml-system.4.14.2 ================================#
# context 2.2.0 | win32/x86_64 | | git+https://github.com/ocaml/opam-repository.git#6c3f73f42890cc19f81eb1dec8023c2cd7b8b5cd
# path ~\AppData\Local\opam\4.14.2\.opam-switch\build\ocaml-system.4.14.2
# command ~\AppData\Local\Programs\DKMLNA~1\usr\bin\ocaml.exe gen_ocaml_config.ml
# exit-code 2
# env-file ~\AppData\Local\opam\log\ocaml-system-2328-86662a.env
# output-file ~\AppData\Local\opam\log\ocaml-system-2328-86662a.out
### output ###
# Exception:
# Sys_error
# "C:\\Users\\shuri\\AppData\\Local\\Programs\\DKMLNA~1\\usr\\bin\\ocaml-realc.exe: No such file or directory".

<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><> 🐫
┌─ The following actions failed
│ λ build ocaml-system 4.14.2
└─
┌─ The following changes have been performed (the rest was aborted)
│ ∗ install base-bigarray base
│ ∗ install base-threads base
│ ∗ install base-unix base
└─
# Run (& opam env --switch=4.14.2) -split '\r?\n' | ForEach-Object { Invoke-Expression $_ } to update the current shell
environment
Switch initialisation failed: clean up? ('n' will leave the switch partially installed) [y/n]

```

\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<  
input:

```auto
dkml version

```

output:

```auto
2.1.1

```

\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<\<

input:

```auto
dkml init --system

```

output:

```auto
dkml: FATAL: opam: no such command in "C:\Users\shuri\AppData\Local\Programs\DKMLNA~1\bin"

```

Perhaps the best course of action would be to remove completely ocaml from my machine.

---

<div class="post-metadata">

### Author: ![pyvovale](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/pyvovale/32/5489_2.png) [@pyvovale](https://discuss.ocaml.org/u/pyvovale)
#### Post date: [August 13, 2024, 2:13am UTC](https://discuss.ocaml.org/t/creating-opam-switch-version-5-3-0-trunk/15121/10 "2024-08-13T02:13:33Z")

</div>

After re-installing everything:

```auto
opam --version

```

```auto
2.2.0

```

```auto
opam update

```

```auto
<><> Updating package repositories ><><><><><><><><><><><><><><><><><><><><> 🐫
[diskuv-2.1.1] no changes from git+https://github.com/diskuv/diskuv-opam-repository.git#2.1.1
[default] no changes from git+https://github.com/ocaml/opam-repository.git#6c3f73f42890cc19f81eb1dec8023c2cd7b8b5cd

```

```auto
opam switch create ocaml_53 5.3.0+trunk

```

```auto
<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><> 🐫
Switch invariant: ["ocaml-variants" {= "5.3.0+trunk"}]

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><> 🐫
∗ installed base-bigarray.base
∗ installed base-threads.base
∗ installed base-unix.base
⬇ retrieved ocaml-variants.5.3.0+trunk (https://github.com/ocaml/ocaml/archive/trunk.tar.gz)
[ERROR] The compilation of ocaml-variants.5.3.0+trunk failed at "./configure
        --prefix=C:\\Users\\shuri\\AppData\\Local\\opam\\ocaml_53
        --docdir=C:\\Users\\shuri\\AppData\\Local\\opam\\ocaml_53\\doc/ocaml -C --disable-warn-error".

#=== ERROR while compiling ocaml-variants.5.3.0+trunk =========================#
# context 2.2.0 | win32/x86_64 | | git+https://github.com/ocaml/opam-repository.git#6c3f73f42890cc19f81eb1dec8023c2cd7b8b5cd
# path C:\Users\shuri\AppData\Local\opam\ocaml_53\.opam-switch\build\ocaml-variants.5.3.0+trunk
# command C:\Users\shuri\AppData\Local\opam\ocaml_53\.opam-switch\build\ocaml-variants.5.3.0+trunk\./configure --prefix=C:\Users\shuri\AppData\Local\opam\ocaml_53 --docdir=C:\Users\shuri\AppData\Local\opam\ocaml_53\doc/ocaml -C --disable-warn-error
# exit-code 69
# env-file C:\Users\shuri\AppData\Local\opam\log\ocaml-variants-17460-ed2a89.env
# output-file C:\Users\shuri\AppData\Local\opam\log\ocaml-variants-17460-ed2a89.out
### output ###
# [...]
# checking whether stripping libraries is possible... no
# checking if libtool supports shared libraries... yes
# checking whether to build shared libraries... yes
# checking whether to build static libraries... yes
# checking how to run the C preprocessor... cl.exe -E
# checking C compiler vendor... msvc-1929
# checking whether host executables can be run in the build... yes
# checking whether #! works in shell scripts... yes
# checking whether the C compiler accepts -Wold-style-declaration... no
# checking whether the C compiler accepts -Wimplicit-fallthrough=5... no
# checking whether the C compiler accepts -Wimplicit-fallthrough... no
# configure: error: This version of MSVC is too old. Please use Visual Studio version 17.8 or above.

<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><> 🐫
┌─ The following actions failed
│ λ build ocaml-variants 5.3.0+trunk
└─
┌─ The following changes have been performed (the rest was aborted)
│ ∗ install base-bigarray base
│ ∗ install base-threads base
│ ∗ install base-unix base
└─
# Run (& opam env --switch=ocaml_53) -split '\r?\n' | ForEach-Object { Invoke-Expression $_ } to update the current
shell environment
Switch initialisation failed: clean up? ('n' will leave the switch partially installed) [y/n]

```

---

<div class="post-metadata">

### Author: ![jbeckford](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/jbeckford/32/3027_2.png) [@jbeckford](https://discuss.ocaml.org/u/jbeckford)
#### Post date: [August 13, 2024, 6:18am UTC](https://discuss.ocaml.org/t/creating-opam-switch-version-5-3-0-trunk/15121/11 "2024-08-13T06:18:32Z")

</div>

These threads are hard to follow for me since it is unclear what set of instructions you are following. Is there a webpage that is telling you to install `5.3.0+trunk` or `5.1.1` on Windows (please link), or you doing that because you just want to explore what works / doesn’t work on Windows?

(I’m expecting most people to be following [https://ocaml.org/docs/installing-ocaml](https://ocaml.org/docs/installing-ocaml), but that doesn’t mention the commands you are running.)

---

<div class="post-metadata">

### Author: ![pyvovale](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/pyvovale/32/5489_2.png) [@pyvovale](https://discuss.ocaml.org/u/pyvovale)
#### Post date: [August 13, 2024, 6:47pm UTC](https://discuss.ocaml.org/t/creating-opam-switch-version-5-3-0-trunk/15121/12 "2024-08-13T18:47:37Z")

</div>

The chaotic nature of these recent posts reflects my confusion about the process. I do not know if there is a page for windows specifically that explains how to set up a switch with Ocaml version \> 5.0.0. Let me make a small recap:

1. installed Ocaml on windows the usual way, meaning the dkml distribution that you mentioned in the link above
2. realised that I was not able to create a switch
3. now I am trying to figure out how to get the desired switch. I suspect that my problem has something to do with opam.exe

Just to be clear I have Ocaml 4.14.2, with all the tooling and everything appears to be working, although I had to re-install it. I would like to know if I could set up a switch with the latest version to start a new experimentation phase. Feel free to ask me more questions if you would like to help me with that.

Actually, is it even possible to get the latest(5.2.0) Ocaml version on Windows?

---

<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: [August 13, 2024, 7:52pm UTC](https://discuss.ocaml.org/t/creating-opam-switch-version-5-3-0-trunk/15121/13 "2024-08-13T19:52:03Z")

</div>

DkML supports OCaml 4.14.2 (check the release notes of the latest release).

For OCaml 5+ on Windows you can try installing the new opam version: [opam - Platform Blog](https://opam.ocaml.org/blog/opam-2-2-0/)

However be warned that the DkML distribution and the standard opam distribution may conflict with each other. You would be recommended to stick with one or the other unless you really know what you are doing.

---

<div class="post-metadata">

### Author: ![jbeckford](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/jbeckford/32/3027_2.png) [@jbeckford](https://discuss.ocaml.org/u/jbeckford)
#### Post date: [August 13, 2024, 8:38pm UTC](https://discuss.ocaml.org/t/creating-opam-switch-version-5-3-0-trunk/15121/14 "2024-08-13T20:38:28Z")

</div>

To add onto @yawaramin’s answer, you can completely remove DkML including the opam root and global switches with [Problem with platform tools installation - #2 by jbeckford](https://discuss.ocaml.org/t/problem-with-platform-tools-installation/15089/2).

I don’t believe 5.1.1 works with _(EDIT:)_ ~~Windows~~ MSVC, and I’m unsure about trunk (but that should work).

---

<div class="post-metadata">

### Author: ![Rucikir](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/rucikir/32/2094_2.png) [@Rucikir](https://discuss.ocaml.org/u/Rucikir)
#### Post date: [August 13, 2024, 10:38pm UTC](https://discuss.ocaml.org/t/creating-opam-switch-version-5-3-0-trunk/15121/15 "2024-08-13T22:38:50Z")

</div>

On Windows, only the MinGW-w64 port is supported in OCaml 5.0 and the Cygwin port is restored in 5.1. Currently 5.3+trunk supports MSVC and clang-cl. OCaml needs at least Visual Studio 2022 version 17.8 (`_MSC_VER` = 1938), but you’re using Visual Studio 2019 version 16.10, 16.11 (`_MSC_VER` = 1929). If you want to use OCaml 5.3+trunk on Windows with MSVC, I suggest you update to the latest Visual Studio 2022. If you want to use OCaml 4.14, everything should work correctly, but I still suggest you switch to VS2022.

---

<div class="post-metadata">

### Author: ![pyvovale](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/pyvovale/32/5489_2.png) [@pyvovale](https://discuss.ocaml.org/u/pyvovale)
#### Post date: [August 13, 2024, 11:13pm UTC](https://discuss.ocaml.org/t/creating-opam-switch-version-5-3-0-trunk/15121/16 "2024-08-13T23:13:55Z")

</div>

Actually, I have VS2022, but the command

```auto
winget install Microsoft.VisualStudio.2019.BuildTools --override "--wait --passive --installPath C:\VS --addProductLang En-us --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended"

```

installs Visual Studio Build Tools 2019, and somehow the newer version(17.11.0) is not detected. It appears that I have now several MSVC versions.

That command is the first step in installing OCaml for windows. If I remove Visual Studio Build Tools 2019, everything breaks.

Do you know how to switch to the latest MSVC version?

---

<div class="post-metadata">

### Author: ![dra27](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/dra27/32/5294_2.png) [@dra27](https://discuss.ocaml.org/u/dra27)
#### Post date: [August 18, 2024, 7:27am UTC](https://discuss.ocaml.org/t/creating-opam-switch-version-5-3-0-trunk/15121/17 "2024-08-18T07:27:14Z")

</div>

What’s probably happening is that the VS 2022 doesn’t have the required tools (C compiler, Windows SDK, etc.) so it’s being ignored. If you’re installing Visual Studio using the graphical installer, ensure you have at least “MSVC v143 - VS 2022 C++ x64/x86 build tools (Latest)”, “Windows 11 SDK (10.0.22621.0)” and “C++/CLI support for v143 build tools (Latest)” selected.

You should also just be able to add VS 2022 build tools with:

```auto
winget install Microsoft.VisualStudio.2022.BuildTools --override "--add Microsoft.VisualStudio.Workload.VCTools --includeRecommended --passive"

```

It’s also possible to run `msvs-detect` directly to see what it’s detecting, but that’s not as easy as it should be in opam (clone [GitHub - metastack/msvs-tools: Microsoft Visual Studio Helper Scripts (OCaml)](https://github.com/metastack/msvs-tools) and run `./msvs-detect --all` from with a Cygwin/MSYS2 bash prompt and it will indicate which versions are valid). I’ve opened [Getting correct Visual Studio 2022 for OCaml 5.3+ · Issue #7 · ocaml-windows/papercuts · GitHub](https://github.com/ocaml-windows/papercuts/issues/7).

---

<div class="post-metadata">

### Author: ![dra27](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/dra27/32/5294_2.png) [@dra27](https://discuss.ocaml.org/u/dra27)
#### Post date: [August 18, 2024, 7:32am UTC](https://discuss.ocaml.org/t/creating-opam-switch-version-5-3-0-trunk/15121/18 "2024-08-18T07:32:37Z")

</div>

> [@jbeckford](#):
>
> I don’t believe 5.1.1 works with Windows, and I’m unsure about trunk (but that should work)

Just for the casual Googler finding the thread:

- The mingw-w64 port has _always_ worked. i.e. mingw-w64 OCaml is fine in all versions of OCaml 4.x and 5.x in both 32 and 64-bit versions, with the standard OCaml 5.x caveat that 32-bit is bytecode-only.
- The Cygwin port of OCaml is _very rarely_ what anyone actually wants on Windows - it was not available in OCaml 5.0.0, but was restored in OCaml 5.1.0 (in 64-bit only - with full native code support - because 32-bit Cygwin is unsupported upstream).
- The MSVC port of OCaml will be restored in OCaml 5.3.0 (32-bit and 64-bit with native code support), but is not available in OCaml 5.0.0 or OCaml 5.1.x. It _is_ available in opam-repository for OCaml 5.2.0 with `opam switch create 5.2.0-msvc ocaml-variants.5.2.0+msvc` but, as found here, a working installation of Visual Studio 2022 must be available for it. OCaml 4.x works with any version of Visual Studio (as long as you can install it!)

---

<div class="post-metadata">

### Author: ![pyvovale](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/pyvovale/32/5489_2.png) [@pyvovale](https://discuss.ocaml.org/u/pyvovale)
#### Post date: [August 18, 2024, 9:04am UTC](https://discuss.ocaml.org/t/creating-opam-switch-version-5-3-0-trunk/15121/19 "2024-08-18T09:04:05Z")

</div>

I ran that command and it told me that the package has been installed and after attempting to update, no new version has been found

---

<div class="post-metadata">

### Author: ![dra27](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/dra27/32/5294_2.png) [@dra27](https://discuss.ocaml.org/u/dra27)
#### Post date: [August 18, 2024, 9:28am UTC](https://discuss.ocaml.org/t/creating-opam-switch-version-5-3-0-trunk/15121/20 "2024-08-18T09:28:37Z")

</div>

> [@pyvovale](#):
>
> and after attempting to update

What do you mean by this?

[Next page](https://discuss.ocaml.org/t/creating-opam-switch-version-5-3-0-trunk/15121.md?page=2)
