I am trying to setup opam and OCaml on a fresh Windows 11 machine. Installing Git and opam per se with winget worked, as well as opam init --root="C:\Opam" --bare
with the offered internal Cygwin system.
However, opam --root="C:\Opam" switch create default 5.3.0
fails on configuring ocaml. The opam log file contains the message C compiler cannot create executables
. It also says to look for more details in a configure.log
file, but it is unclear to me where that file would be.
Does anybody have pointers for this ?
Note that I successfully installed 5.3.0 in a Windows 10 virtual machine (although not a fresh one).
Are you using mingw or msvc? I’ve been able to setup both on Windows 11 by doing opam switch create foo --packages ocaml-compiler.5.3.0,system-msvc
and system-mingw
.
I do not know, I am just following what opam recommends (ie. “Cygwin internal install”), which downloaded and, presumably, installed some cygwin system in C:\Opam\.cygwin
).
I was able to extract the log files. It appears the configure script cannot find x86_64-w64-mingw32-gcc.exe
!
Since I cannot upload log file as attachments, here is their content :
Environment :
=::=::\
ALLUSERS=TRUE
ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\Administrateur\AppData\Roaming
ASAN_OPTIONS=detect_leaks=0,exitcode=0
CC='x86_64-w64-mingw32-gcc.exe'
CDPATH=
CommonProgramFiles=C:\Program Files\Common Files
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
CommonProgramW6432=C:\Program Files\Common Files
COMPUTERNAME=MASTER-HPG-W11
ComSpec=C:\WINDOWS\system32\cmd.exe
CPP='x86_64-w64-mingw32-cpp.exe'
DriverData=C:\Windows\System32\Drivers\DriverData
EFC_8484_1592913036=1
FILEEXTDESC=Fichier d’image thermique Fluke
HOMEDRIVE=C:
HOMEPATH=\Users\Administrateur
LANGUAGE=fr
LOCALAPPDATA=C:\Users\Administrateur\AppData\Local
LOGONSERVER=\\MASTER-HPG-W11
LSAN_OPTIONS=detect_leaks=0,exitcode=0
MAKEFLAGS=
MAKELEVEL=
MANPATH=:/cygdrive/c/Opam/default/man
MESSAGE_NEWER_VERSION_ALREADY_INSTALLED=La nouvelle version est déjà installée.
MSYS2_ARG_CONV_EXCL=*
NUMBER_OF_PROCESSORS=4
OneDrive=C:\Users\Administrateur\OneDrive
OPAM_PACKAGE_NAME=ocaml-compiler
OPAM_PACKAGE_VERSION=5.3.0
OPAM_SWITCH_PREFIX=C:\Opam\default
OPAMCLI=2.0
OPAMROOT=C:\Opam
OPAMSWITCH=default
OS=Windows_NT
Path=C:\Opam\default\bin;C:\Opam\.cygwin\root\usr\x86_64-w64-mingw32\sys-root\mingw\bin;C:\Program Files (x86)\Common Files\Oracle\Java\java8path;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Opam\.cygwin\root\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files (x86)\Avogadro\bin;C:\Program Files\Graphviz\bin;C:\Program Files\Git\cmd;C:\Program Files\swipl\bin;C:\Program Files (x86)\ffmpeg;C:\mingw64\bin;C:\texlive\2025\bin\windows;C:\Program Files\gs\gs10.05.1\bin;C:\Program Files\Emacs\emacs-30.1\bin;C:\Users\Administrateur\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Microsoft VS Code\bin;C:\Users\Administrateur\AppData\Local\Microsoft\WinGet\Links;
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.CPL
PROCESSOR_ARCHITECTURE=AMD64
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 151 Stepping 5, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=9705
ProgramData=C:\ProgramData
ProgramFiles=C:\Program Files
ProgramFiles(x86)=C:\Program Files (x86)
ProgramW6432=C:\Program Files
PSModulePath=C:\Users\Administrateur\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
PUBLIC=C:\Users\Public
SESSIONNAME=Console
SystemDrive=C:
SystemRoot=C:\WINDOWS
TEMP=C:\Users\ADMINI~1\AppData\Local\Temp
TEXMFLOCAL=P:\Mes documents\texmf
TMP=C:\Users\ADMINI~1\AppData\Local\Temp
USERDOMAIN=MASTER-HPG-W11
USERDOMAIN_ROAMINGPROFILE=MASTER-HPG-W11
USERNAME=Administrateur
USERPROFILE=C:\Users\Administrateur
windir=C:\WINDOWS
ZES_ENABLE_SYSMAN=1
config.log :
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by OCaml configure 5.3.0, which was
generated by GNU Autoconf 2.71. Invocation command line was
$ C:\Opam\default\.opam-switch\build\ocaml-compiler.5.3.0\./configure --host=x86_64-w64-mingw32 '--prefix=C:\Opam\default' '--docdir=C:\Opam\default\doc/ocaml' '--with-flexdll=C:\Opam\default\share\flexdll' -C --disable-warn-error
## --------- ##
## Platform. ##
## --------- ##
hostname = MASTER-HPG-W11
uname -m = x86_64
uname -r = 3.6.3-1.x86_64
uname -s = CYGWIN_NT-10.0-26100
uname -v = 2025-06-05 11:45 UTC
/usr/bin/uname -p = unknown
/bin/uname -X = unknown
/bin/arch = x86_64
/usr/bin/arch -k = unknown
/usr/convex/getsysinfo = unknown
/usr/bin/hostinfo = unknown
/bin/machine = unknown
/usr/bin/oslevel = unknown
/bin/universe = unknown
PATH: /cygdrive/c/Opam/default/bin/
PATH: /usr/x86_64-w64-mingw32/sys-root/mingw/bin/
PATH: /cygdrive/c/Program Files (x86)/Common Files/Oracle/Java/java8path/
PATH: /cygdrive/c/Program Files (x86)/Common Files/Oracle/Java/javapath/
PATH: /usr/bin/
PATH: /cygdrive/c/WINDOWS/system32/
PATH: /cygdrive/c/WINDOWS/
PATH: /cygdrive/c/WINDOWS/System32/Wbem/
PATH: /cygdrive/c/WINDOWS/System32/WindowsPowerShell/v1.0/
PATH: /cygdrive/c/WINDOWS/System32/OpenSSH/
PATH: /cygdrive/c/Program Files (x86)/Avogadro/bin/
PATH: /cygdrive/c/Program Files/Graphviz/bin/
PATH: /cygdrive/c/Program Files/Git/cmd/
PATH: /cygdrive/c/Program Files/swipl/bin/
PATH: /cygdrive/c/Program Files (x86)/ffmpeg/
PATH: /cygdrive/c/mingw64/bin/
PATH: /cygdrive/c/texlive/2025/bin/windows/
PATH: /cygdrive/c/Program Files/gs/gs10.05.1/bin/
PATH: /cygdrive/c/Program Files/Emacs/emacs-30.1/bin/
PATH: /cygdrive/c/Users/Administrateur/AppData/Local/Microsoft/WindowsApps/
PATH: /cygdrive/c/Program Files/Microsoft VS Code/bin/
PATH: /cygdrive/c/Users/Administrateur/AppData/Local/Microsoft/WinGet/Links/
## ----------- ##
## Core tests. ##
## ----------- ##
configure:2775: creating cache config.cache
configure:3111: looking for aux files: install-sh ltmain.sh config.guess config.sub
configure:3124: trying ./build-aux/
configure:3135: ./build-aux/install-sh found
configure:3153: ./build-aux/ltmain.sh found
configure:3153: ./build-aux/config.guess found
configure:3153: ./build-aux/config.sub found
configure:3265: Configuring OCaml version 5.3.0
configure:3586: checking build system type
configure:3601: result: x86_64-pc-cygwin
configure:3621: checking host system type
configure:3635: result: x86_64-w64-mingw32
configure:3655: checking target system type
configure:3669: result: x86_64-w64-mingw32
configure:3742: checking for csc
configure:3777: result: no
configure:4237: checking for x86_64-w64-mingw32-ld
configure:4258: found /cygdrive/c/Opam/default/bin/x86_64-w64-mingw32-ld
configure:4269: result: x86_64-w64-mingw32-ld
configure:4400: checking how to print strings
configure:4427: result: printf
configure:4465: checking for x86_64-w64-mingw32-gcc
configure:4497: result: 'x86_64-w64-mingw32-gcc.exe'
configure:4895: checking for C compiler version
configure:4904: 'x86_64-w64-mingw32-gcc.exe' --version >&5
C:\Opam\default\.opam-switch\build\ocaml-compiler.5.3.0\./configure: line 4906: 'x86_64-w64-mingw32-gcc.exe': command not found
configure:4915: $? = 127
configure:4904: 'x86_64-w64-mingw32-gcc.exe' -v >&5
C:\Opam\default\.opam-switch\build\ocaml-compiler.5.3.0\./configure: line 4906: 'x86_64-w64-mingw32-gcc.exe': command not found
configure:4915: $? = 127
configure:4904: 'x86_64-w64-mingw32-gcc.exe' -V >&5
C:\Opam\default\.opam-switch\build\ocaml-compiler.5.3.0\./configure: line 4906: 'x86_64-w64-mingw32-gcc.exe': command not found
configure:4915: $? = 127
configure:4904: 'x86_64-w64-mingw32-gcc.exe' -qversion >&5
C:\Opam\default\.opam-switch\build\ocaml-compiler.5.3.0\./configure: line 4906: 'x86_64-w64-mingw32-gcc.exe': command not found
configure:4915: $? = 127
configure:4904: 'x86_64-w64-mingw32-gcc.exe' -version >&5
C:\Opam\default\.opam-switch\build\ocaml-compiler.5.3.0\./configure: line 4906: 'x86_64-w64-mingw32-gcc.exe': command not found
configure:4915: $? = 127
configure:4935: checking whether the C compiler works
configure:4957: 'x86_64-w64-mingw32-gcc.exe' conftest.c >&5
C:\Opam\default\.opam-switch\build\ocaml-compiler.5.3.0\./configure: line 4959: 'x86_64-w64-mingw32-gcc.exe': command not found
configure:4961: $? = 127
configure:5001: result: no
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "OCaml"
| #define PACKAGE_TARNAME "ocaml"
| #define PACKAGE_VERSION "5.3.0"
| #define PACKAGE_STRING "OCaml 5.3.0"
| #define PACKAGE_BUGREPORT "caml-list@inria.fr"
| #define PACKAGE_URL "http://www.ocaml.org"
| #define MAGIC_NUMBER_PREFIX "Caml1999"
| #define MAGIC_NUMBER_VERSION "035"
| #define EXEC_MAGIC_LENGTH 12
| #define EXEC_FORMAT "X"
| #define OCAML_VERSION_MAJOR 5
| #define OCAML_VERSION_MINOR 3
| #define OCAML_VERSION_PATCHLEVEL 0
| #define OCAML_VERSION_ADDITIONAL ""
| #define OCAML_VERSION_EXTRA ""
| #define OCAML_VERSION 50300
| #define OCAML_VERSION_STRING "5.3.0"
| /* end confdefs.h. */
|
| int
| main (void)
| {
|
| ;
| return 0;
| }
configure:5006: error: in `/cygdrive/c/Opam/default/.opam-switch/build/ocaml-compiler.5.3.0':
configure:5008: error: C compiler cannot create executables
See `config.log' for more details
## ---------------- ##
## Cache variables. ##
## ---------------- ##
ac_cv_build=x86_64-pc-cygwin
ac_cv_env_ASPP_set=
ac_cv_env_ASPP_value=
ac_cv_env_AS_set=
ac_cv_env_AS_value=
ac_cv_env_CC_set=set
ac_cv_env_CC_value=''\''x86_64-w64-mingw32-gcc.exe'\'''
ac_cv_env_CFLAGS_set=
ac_cv_env_CFLAGS_value=
ac_cv_env_COMPILER_BYTECODE_CFLAGS_set=
ac_cv_env_COMPILER_BYTECODE_CFLAGS_value=
ac_cv_env_COMPILER_BYTECODE_CPPFLAGS_set=
ac_cv_env_COMPILER_BYTECODE_CPPFLAGS_value=
ac_cv_env_COMPILER_NATIVE_CFLAGS_set=
ac_cv_env_COMPILER_NATIVE_CFLAGS_value=
ac_cv_env_COMPILER_NATIVE_CPPFLAGS_set=
ac_cv_env_COMPILER_NATIVE_CPPFLAGS_value=
ac_cv_env_CPPFLAGS_set=
ac_cv_env_CPPFLAGS_value=
ac_cv_env_CPP_set=set
ac_cv_env_CPP_value=''\''x86_64-w64-mingw32-cpp.exe'\'''
ac_cv_env_DEFAULT_STRING_set=
ac_cv_env_DEFAULT_STRING_value=
ac_cv_env_DLLIBS_set=
ac_cv_env_DLLIBS_value=
ac_cv_env_LDFLAGS_set=
ac_cv_env_LDFLAGS_value=
ac_cv_env_LIBS_set=
ac_cv_env_LIBS_value=
ac_cv_env_LIBUNWIND_CPPFLAGS_set=
ac_cv_env_LIBUNWIND_CPPFLAGS_value=
ac_cv_env_LIBUNWIND_LDFLAGS_set=
ac_cv_env_LIBUNWIND_LDFLAGS_value=
ac_cv_env_LT_SYS_LIBRARY_PATH_set=
ac_cv_env_LT_SYS_LIBRARY_PATH_value=
ac_cv_env_PARTIALLD_set=
ac_cv_env_PARTIALLD_value=
ac_cv_env_WINDOWS_UNICODE_MODE_set=
ac_cv_env_WINDOWS_UNICODE_MODE_value=
ac_cv_env_build_alias_set=
ac_cv_env_build_alias_value=
ac_cv_env_host_alias_set=set
ac_cv_env_host_alias_value=x86_64-w64-mingw32
ac_cv_env_target_alias_set=
ac_cv_env_target_alias_value=
ac_cv_host=x86_64-w64-mingw32
ac_cv_prog_CC=''\''x86_64-w64-mingw32-gcc.exe'\'''
ac_cv_prog_LD=x86_64-w64-mingw32-ld
ac_cv_target=x86_64-w64-mingw32
## ----------------- ##
## Output variables. ##
## ----------------- ##
AR=''
AS=''
ASPP=''
AST_IMPL_MAGIC_NUMBER='Caml1999M035'
AST_INTF_MAGIC_NUMBER='Caml1999N035'
AWK=''
CC=''\''x86_64-w64-mingw32-gcc.exe'\'''
CFLAGS=''
CMA_MAGIC_NUMBER='Caml1999A035'
CMI_MAGIC_NUMBER='Caml1999I035'
CMO_MAGIC_NUMBER='Caml1999O035'
CMT_MAGIC_NUMBER='Caml1999T035'
CMXA_MAGIC_NUMBER=''
CMXS_MAGIC_NUMBER='Caml1999D035'
CMX_MAGIC_NUMBER=''
COMPILER_BYTECODE_CFLAGS=''
COMPILER_BYTECODE_CPPFLAGS=''
COMPILER_NATIVE_CFLAGS=''
COMPILER_NATIVE_CPPFLAGS=''
CONFIGURE_ARGS='--host=x86_64-w64-mingw32 --prefix=C:\Opam\default --docdir=C:\Opam\default\doc/ocaml --with-flexdll=C:\Opam\default\share\flexdll -C --disable-warn-error'
CPP=''\''x86_64-w64-mingw32-cpp.exe'\'''
CPPFLAGS=''
CSC=''
CSCFLAGS=''
DEFAULT_STRING=''
DEFS=''
DEP_CC=''
DIFF=''
DIFF_FLAGS=''
DIRECT_LD=''
DLLIBS=''
DLLTOOL=''
DSYMUTIL=''
DUMPBIN=''
ECHO_C=''
ECHO_N='-n'
ECHO_T=''
EGREP=''
EXEC_MAGIC_NUMBER='Caml1999X035'
EXEEXT=''
FGREP=''
GREP=''
INSTALL_DATA=''
INSTALL_PROGRAM=''
INSTALL_SCRIPT=''
LD='x86_64-w64-mingw32-ld'
LDFLAGS=''
LIBOBJS=''
LIBS=''
LIBTOOL=''
LIBUNWIND_CPPFLAGS=''
LIBUNWIND_LDFLAGS=''
LINEAR_MAGIC_NUMBER='Caml1999L035'
LIPO=''
LN_S=''
LTLIBOBJS=''
LT_SYS_LIBRARY_PATH=''
MAGIC_LENGTH='12'
MANIFEST_TOOL=''
NM=''
NMEDIT=''
OBJDUMP=''
OBJEXT=''
OCAML_DEVELOPMENT_VERSION='false'
OCAML_RELEASE_EXTRA='None'
OCAML_VERSION_EXTRA=''
OCAML_VERSION_MAJOR='5'
OCAML_VERSION_MINOR='3'
OCAML_VERSION_PATCHLEVEL='0'
OCAML_VERSION_SHORT='5.3'
OTOOL64=''
OTOOL=''
PACKAGE_BUGREPORT='caml-list@inria.fr'
PACKAGE_NAME='OCaml'
PACKAGE_STRING='OCaml 5.3.0'
PACKAGE_TARNAME='ocaml'
PACKAGE_URL='http://www.ocaml.org'
PACKAGE_VERSION='5.3.0'
PACKLD=''
PARTIALLD=''
PATH_SEPARATOR=':'
PKG_CONFIG=''
PTHREAD_CC=''
PTHREAD_CFLAGS=''
PTHREAD_CXX=''
PTHREAD_LIBS=''
QS=''
RANLIB=''
S='s'
SED=''
SHELL='/bin/sh'
SO='so'
STRIP=''
VERSION='5.3.0'
WINDOWS_UNICODE_MODE=''
ac_ct_AR=''
ac_ct_CC=''
ac_ct_DEP_CC=''
ac_ct_DUMPBIN=''
ac_ct_LD=''
ac_tool_prefix='x86_64-w64-mingw32-'
afl=''
ar_supports_response_files=''
arch64=''
arch=''
arch_specific_SOURCES=''
as_has_debug_prefix_map=''
asm_cfi_supported=''
ax_pthread_config=''
bindir='${exec_prefix}/bin'
bootstrapping_flexdll='false'
build='x86_64-pc-cygwin'
build_alias=''
build_cpu='x86_64'
build_libraries_manpages=''
build_ocamldebug=''
build_ocamldoc='true'
build_ocamlobjinfo=''
build_ocamltest=''
build_ocamltex='true'
build_os='cygwin'
build_vendor='pc'
bytecode_cflags=''
bytecode_cppflags=''
cc_has_debug_prefix_map=''
cclibs=''
ccomptype='cc'
cmm_invariants=''
cmxs=''
common_cflags=''
common_cppflags=''
compute_deps=''
csc=''
datadir='${datarootdir}'
datarootdir='${prefix}/share'
debug_runtime=''
default_build_target=''
docdir='C:\Opam\default\doc/ocaml'
documentation_tool=''
documentation_tool_cmd=''
dvidir='${docdir}'
endianness=''
exec_prefix='NONE'
exeext=''
flambda=''
flambda_invariants=''
flat_float_array=''
flexdll_chain=''
flexdll_dir=''
flexdll_source_dir=''
flexlink=''
fpic=''
frame_pointers=''
function_sections=''
host='x86_64-w64-mingw32'
host_alias='x86_64-w64-mingw32'
host_cpu='x86_64'
host_os='mingw32'
host_vendor='w64'
htmldir='${docdir}'
includedir='${prefix}/include'
infodir='${datarootdir}/info'
install_bytecode_programs=''
install_ocamlnat=''
install_source_artifacts=''
instrumented_runtime='false'
instrumented_runtime_libs=''
lib_dynlink='false'
lib_runtime_events=''
lib_str='false'
lib_systhreads='false'
lib_unix='false'
libdir='${exec_prefix}/lib'
libexecdir='${exec_prefix}/libexec'
libext=''
ln=''
localedir='${datarootdir}/locale'
localstatedir='${prefix}/var'
mandir='${datarootdir}/man'
mkdll=''
mkdll_exp=''
mkexe=''
mkexe_exp=''
mkexe_via_cc_extra_cmd=''
mkexe_via_cc_ldflags=''
mkexedebugflag='-g'
mklib=''
mkmaindll=''
mkmaindll_exp=''
mksharedlibrpath=''
model=''
natdynlink=''
natdynlink_archive=''
natdynlinkopts=''
native_cflags=''
native_compiler=''
native_cppflags=''
native_ldflags=''
oc_bytecode_cflags=''
oc_bytecode_cppflags=''
oc_cflags=''
oc_cppflags=''
oc_dll_ldflags=''
oc_ldflags=''
oc_native_cflags=''
oc_native_compflags=''
oc_native_cppflags=''
ocaml_bindir=''
ocaml_libdir=''
ocamldoc_opt_target='ocamldoc.opt'
ocamldoc_target='ocamldoc'
ocamlsrcdir=''
ocamltest=''
ocamltest_CPP=''
ocamltest_libunix='None'
ocamltest_opt_target=''
ocamltest_target=''
ocamlyacc_wstr_module=''
oldincludedir='/usr/include'
optional_bytecode_tools=''
optional_libraries=' ocamldoc/odoc_info'
optional_native_tools=''
otherlibraries=''
otherlibs=''
outputexe='-o '
outputobj=''
pdfdir='${docdir}'
prefix='C:\Opam\default'
program_transform_name='s,x,x,'
psdir='${docdir}'
reserved_header_bits='0'
rlwrap=''
rpath=''
runstatedir='${localstatedir}/run'
runtime_asm_objects=''
sbindir='${exec_prefix}/sbin'
sharedlib_cflags=''
sharedstatedir='${prefix}/com'
shebangscripts=''
supports_shared_libraries=''
sysconfdir='${prefix}/etc'
syslib='-l$(1)'
system=''
systhread_support=''
target='x86_64-w64-mingw32'
target_alias=''
target_cpu='x86_64'
target_os='mingw32'
target_vendor='w64'
toolchain='cc'
tsan='false'
tsan_native_runtime_c_sources=''
unix_directory=''
unix_library=''
unix_or_win32=''
windows_unicode=''
winpthreads_source_dir=''
winpthreads_source_include_dir=''
with_debugger=''
with_ocamldoc='ocamldoc'
zstd_libs=''
## ----------- ##
## confdefs.h. ##
## ----------- ##
/* confdefs.h */
#define PACKAGE_NAME "OCaml"
#define PACKAGE_TARNAME "ocaml"
#define PACKAGE_VERSION "5.3.0"
#define PACKAGE_STRING "OCaml 5.3.0"
#define PACKAGE_BUGREPORT "caml-list@inria.fr"
#define PACKAGE_URL "http://www.ocaml.org"
#define MAGIC_NUMBER_PREFIX "Caml1999"
#define MAGIC_NUMBER_VERSION "035"
#define EXEC_MAGIC_LENGTH 12
#define EXEC_FORMAT "X"
#define OCAML_VERSION_MAJOR 5
#define OCAML_VERSION_MINOR 3
#define OCAML_VERSION_PATCHLEVEL 0
#define OCAML_VERSION_ADDITIONAL ""
#define OCAML_VERSION_EXTRA ""
#define OCAML_VERSION 50300
#define OCAML_VERSION_STRING "5.3.0"
configure: exit 77
Maybe somebody can spot a difference in their environment ?
I think I found the problem. The CC
environment variable stems from another C installation, and is not related to opam. For some unknown reason, it still reads it as the name of the C compiler to use. It remains a mystery why it then cannot find it, but in any case, removing that variable solves the problem.