Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opam.2.2~alpha2 env error on Windows 10 with fresh cygwin64 install, libstdc++.6.dll was not found #5728

Closed
aryx opened this issue Nov 14, 2023 · 31 comments · Fixed by #5680
Closed

Comments

@aryx
Copy link

aryx commented Nov 14, 2023

I've followed the instructions on https://opam.ocaml.org/blog/opam-2-2-0-alpha2/ and installed cygwin on
my surface book 2 with windows 10, and installed make, curl, mingw-gcc-g++
but during the compilation of make cold, I got some popup windows
telling me "The code execution cannot proceed because libstdc++6.dll was not found. Reinstalling the program may fix this problem.

Then if I click OK I get another of this error, and so on.

BTW: once opam.exe is working, can ocaml produce executable that do not require cygwin dlls on user's machine?

@aryx
Copy link
Author

aryx commented Nov 14, 2023

Same problem with 2.2~alpha3 that I just downloaded.

@aryx
Copy link
Author

aryx commented Nov 14, 2023

It's from a fresh cygwin64 install, so not sure what's going on. I can manually fix some path and add some symlink to libsdc++6.dll but this seems gross (or the issue is cygwin is broken?)

@rjbou
Copy link
Collaborator

rjbou commented Nov 14, 2023

You need to add C:\cygwin64\usr\x86_64-w64-mingw32\sys-root\mingw\bin to you path (adapt with your cygwin prefix).
See Hint in blogpost

Hint: if you use the MinGW compiler, don't forget to add to your PATH the path to libc dlls (usually C:\cygwin64\usr\x86_64-w64-mingw32\sys-root\mingw\bin). Or compile opam with make cold CONFIGURE_ARGS=--with-private-runtime, and if you change opam location, don't forget to copy Opam.Runtime.amd64 (or Opam.Runtime.i386) with it.

@aryx
Copy link
Author

aryx commented Nov 14, 2023

Oh sorry, how did I miss that ...

@aryx
Copy link
Author

aryx commented Nov 14, 2023

Regarding my other question, if I use mingw gcc, do the .exe produced by ocamlopt will require cygwin.dll?
Can we compile fully "native" windows executables?
I find the documentation on this topic unclear.

@rjbou
Copy link
Collaborator

rjbou commented Nov 14, 2023

Compiled opam is always dependent on dlls. They can be on system (the addition in path), or you can fetch them on a single directory (the --with-private-runtime option).
We did some test for a static binary (cf #5680), that permit us to generate an first experimental windows binary to publish (cf Assets). This is experimental build, use it at your own risk.

@aryx
Copy link
Author

aryx commented Nov 14, 2023

Also in the blog post, Hint is maybe not a great name; it's more than an Hint, it would not work without it. Moreover how to set the PATH? You mention a PATH in the blog post, but if you copy paste in cygwin terminal with PATH=$PATH:C:... it does not work because \ is interpreted as an escape character ...

@aryx
Copy link
Author

aryx commented Nov 14, 2023

Maybe the instructions should mention explicitely the exact command to run to setup this PATH.

@kit-ty-kate
Copy link
Member

I made a suggestion to try to improve the blog post for alpha3 in ocaml/platform-blog#96 (review). How does that sound?

@kit-ty-kate
Copy link
Member

Also if the experimental prebuilt windows binary isn’t working for you, please feel free to open a new issue. This present issue should be fixed in the next release by #5680

@aryx
Copy link
Author

aryx commented Nov 14, 2023

done: ocaml/opam-repository#24791 failure with prebuild windows binary

@aryx
Copy link
Author

aryx commented Nov 15, 2023

#5730 failure again with prebuild windows binary

@aryx
Copy link
Author

aryx commented Nov 15, 2023

Ok I've removed cygwin, install vistual studio build tools 2022, and use the prebuild opam binary, and it seems to work!


C:\Users\pad\Downloads>./opam.exe
'.' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\pad\Downloads>opam.exe
usage: opam [--version]
            [--help]
            <command> [<args>]

The most commonly used opam commands are:
    init         Initialize opam state, or set init options.
    list         Display the list of available packages.
    show         Display information about specific packages.
    install      Install a list of packages.
    remove       Remove a list of packages.
    update       Update the list of available packages.
    upgrade      Upgrade the installed package to latest version.
    config       Display configuration options for packages.
    repository   Manage opam repositories.
    switch       Manage multiple installation prefixes.
    pin          Pin a given package to a specific version or source.
    admin        Tools for repository administrators

See 'opam help <command>' for more information on a specific command.

C:\Users\pad\Downloads>opam.exe init git+https://github.com/ocaml-opam/opam-repository-mingw
No configuration file found, using built-in defaults.

<><> Unix support infrastructure ><><><><><><><><><><><><><><><><><><><><><><><>

opam and the OCaml ecosystem in general require various Unix tools in order to operate correctly. At present, this requires the installation of Cygwin to provide these tools.

How should opam handle Cygwin?
> 1. Automatically create an internal Cygwin installation that will be managed by opam
  2. Enter the location of an existing Cygwin installation
  3. Abort initialisation

[1/2/3] 1
[NOTE] Configured with internal Cygwin install for depexts
Checking for available remotes: rsync and local, git.
  - you won't be able to use mercurial repositories unless you install the hg command on your system.
  - you won't be able to use darcs repositories unless you install the darcs command on your system.


<><> Fetching repository information ><><><><><><><><><><><><><><><><><><><><><>
[default] Initialised

<><> Required setup - please read <><><><><><><><><><><><><><><><><><><><><><><>

  In normal operation, opam only alters files within ~\AppData\Local\opam.

  However, to best integrate with your system, some environment variables
  should be set. When you want to access your opam installation, you will
  need to run:

    for /f "tokens=*" %i in ('opam env') do @%i

  You can always re-run this setup with 'opam init' later.

opam doesn't have any configuration options for cmd; you will have to run for /f "tokens=*" %i in ('opam env') do @%i
whenever you change you current 'opam switch' or start a new terminal session. Alternatively, would you like to select
a different shell? [y/n] n

<><> Creating initial switch 'default' (invariant ["ocaml" {>= "4.05.0"}]) ><><>

<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><>
Switch invariant: ["ocaml" {>= "4.05.0"}]

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
✶ installed base-bigarray.base
✶ installed base-threads.base
✶ installed base-unix.base
▼ retrieved ocaml-variants.4.14.1+msvc64c  (https://github.com/ocaml/ocaml/archive/refs/tags/4.14.1.tar.gz)
Processing 13/18: [ocaml-variants: ./configure]

@aryx
Copy link
Author

aryx commented Nov 15, 2023

spoke too fast, another error

@aryx
Copy link
Author

aryx commented Nov 15, 2023

<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><>
Switch invariant: ["ocaml" {>= "4.05.0"}]

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
✶ installed base-bigarray.base
✶ installed base-threads.base
✶ installed base-unix.base
▼ retrieved ocaml-variants.4.14.1+msvc64c  (https://github.com/ocaml/ocaml/archive/refs/tags/4.14.1.tar.gz)
[ERROR] The compilation of ocaml-variants.4.14.1+msvc64c failed at "make SHELL=/bin/dash -j7 world.opt".

#=== ERROR while compiling ocaml-variants.4.14.1+msvc64c ======================#
# context     2.2.0~alpha3 | win32/x86_64 |  | git+https://github.com/ocaml-opam/opam-repository-mingw
# path        ~\AppData\Local\opam\default\.opam-switch\build\ocaml-variants.4.14.1+msvc64c
# command     ~\AppData\Local\opam\.cygwin\root\bin\make.exe SHELL=/bin/dash -j7 world.opt
# exit-code   2
# env-file    ~\AppData\Local\Temp\opam-pad-1992\ocaml-variants-1992-589545.env
# output-file ~\AppData\Local\Temp\opam-pad-1992\ocaml-variants-1992-589545.out
### output ###
# [...]
# cl -c -nologo -O2 -Gy- -MD  -d2VolatileMetadata-  -D_CRT_SECURE_NO_DEPRECATE -I ../flexdll -DCAML_NAME_SPACE -DUNICODE -D_UNICODE -DWINDOWS_UNICODE=1 -DCAMLDLLIMPORT=  -Focodefrag.b.obj codefrag.c
# cl -c -nologo -O2 -Gy- -MD  -d2VolatileMetadata-  -D_CRT_SECURE_NO_DEPRECATE -I ../flexdll -DCAML_NAME_SPACE -DUNICODE -D_UNICODE -DWINDOWS_UNICODE=1 -DCAMLDLLIMPORT=  \
#   -Foprims.obj prims.c
# codefrag.c
# prims.c
# link -lib -nologo -machine:AMD64  /out:libcamlrun_non_shared.lib  interp.b.obj misc.b.obj stacks.b.obj fix_code.b.obj startup_aux.b.obj startup_byt.b.obj freelist.b.obj major_gc.b.obj minor_gc.b.obj memory.b.obj alloc.b.obj roots_byt.b.obj globroots.b.obj fail_byt.b.obj signals.b.obj signals_byt.b.obj printexc.b.obj backtrace_byt.b.obj backtrace.b.obj compare.b.obj ints.b.obj eventlog.b.obj f[...]
# interp.b.obj : fatal error LNK1112: module machine type 'x86' conflicts with target machine type 'x64'
# make[2]: *** [Makefile:277: libcamlrun_non_shared.lib] Error 88
# make[2]: Leaving directory '/cygdrive/c/Users/pad/AppData/Local/opam/default/.opam-switch/build/ocaml-variants.4.14.1+msvc64c/runtime'
# make[1]: *** [Makefile:145: boot/ocamlruns.exe] Error 2
# make[1]: Leaving directory '/cygdrive/c/Users/pad/AppData/Local/opam/default/.opam-switch/build/ocaml-variants.4.14.1+msvc64c'
# make: *** [Makefile:311: world.opt] Error 2



<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
┌─ The following actions failed
│ λ build ocaml-variants 4.14.1+msvc64c
└─
┌─ The following changes have been performed (the rest was aborted)
│ ✶ install base-bigarray base
│ ✶ install base-threads  base
│ ✶ install base-unix     base
└─
# Run for /f "tokens=*" %i in ('opam env --switch=default') do @%i to update the current shell environment
Switch initialisation failed: clean up? ('n' will leave the switch partially installed) [y/n]   y
Switch initialisation failed: clean up? ('n' will leave the switch partially installed) [y/n] y
[NOTE] Opam has been initialised, but the initial switch creation failed.
       Use 'opam switch create <compiler>' to get started.

@aryx
Copy link
Author

aryx commented Nov 15, 2023

created new issue for that here: ocaml/opam-repository#24794

@aryx
Copy link
Author

aryx commented Nov 15, 2023

finally managed to opam switch create 4.14.1+mingw64 but then I can't opam env it:

pad@xayr /cygdrive/c/Users/pad/Downloads
$ eval $(./opam env --switch=4.14.1+mingw64)
-bash: $'\r': command not found
-bash: $'\r': command not found
-bash: $'\r': command not found
-bash: $'\r': command not found
-bash: $'\r': command not found
-bash: $'\r': command not found
-bash: $'\r': command not found
-bash: $'\r': command not found
-bash: $'\r': command not found

@aryx
Copy link
Author

aryx commented Nov 15, 2023

I manually run ./opam env
and then copy pasted in my terminal the assignemts and now ocamlc -v is reporting correctly!
Wow. Tough install.

@kit-ty-kate
Copy link
Member

That’ll get fixed in #5715

@aryx
Copy link
Author

aryx commented Nov 15, 2023

I managed to install a few packages, but I have an error with conf-pkg-config.
It says the command does not exist when it's clearly in my PATH

@aryx
Copy link
Author

aryx commented Nov 15, 2023

Any idea? Known problem?

@aryx
Copy link
Author

aryx commented Nov 15, 2023

(I mean the first time I tried to install it, I didn't have pkg-config, but rerun cygwin setup to install pkg-config, now found it accessible in my PATH, but then I still get the error. Is there some some of caching preventing to retry?)

@kit-ty-kate
Copy link
Member

what sort of error do you get?

@aryx
Copy link
Author

aryx commented Nov 15, 2023

pad@xayr ~
$ pkg-config --list-all
libpcre                        libpcre - PCRE - Perl compatible regular expressions C library with 8 bit character support
libpcre16                      libpcre16 - PCRE - Perl compatible regular expressions C library with 16 bit character support
libpcre32                      libpcre32 - PCRE - Perl compatible regular expressions C library with 32 bit character support
libpcrecpp                     libpcrecpp - PCRECPP - C++ wrapper for PCRE
libpcreposix                   libpcreposix - PCREPosix - Posix compatible interface to libpcre

pad@xayr ~
$ opam install conf-libpcre
The following actions will be performed:
=== install 2 packages
  ∗ conf-libpcre    1
  ∗ conf-pkg-config 2 [required by conf-libpcre]

Proceed with ∗ 2 installations? [y/n] y

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫

#=== ERROR while compiling conf-pkg-config.2 ==================================#
"pkg-config": command not found.


<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫
┌─ The following actions failed
│ λ build conf-pkg-config 2
└─
╶─ No changes have been performed

pad@xayr ~
$

@kit-ty-kate
Copy link
Member

mmh, what does opam env tell you?

@aryx
Copy link
Author

aryx commented Nov 15, 2023

$ opam env
OPAM_LAST_ENV='C:\Users\pad\AppData\Local\opam\4.14.1+mingw64\.opam-switch\last-env\env-099c1c584ee8f6d701e21c9d44727745-0'; export OPAM_LAS
T_ENV;
OPAM_SWITCH_PREFIX='C:\Users\pad\AppData\Local\opam\4.14.1+mingw64'; export OPAM_SWITCH_PREFIX;
OCAMLLIB='C:\Users\pad\AppData\Local\opam\4.14.1+mingw64/lib/ocaml'; export OCAMLLIB;
CC='x86_64-w64-mingw32-gcc.exe'; export CC;
CPP='x86_64-w64-mingw32-cpp.exe'; export CPP;
CAML_LD_LIBRARY_PATH='C:\Users\pad\AppData\Local\opam\4.14.1+mingw64\lib/stublibs;C:/Users/pad/AppData/Local/opam/4.14.1+mingw64/lib/ocaml/s
tublibs;C:/Users/pad/AppData/Local/opam/4.14.1+mingw64/lib/ocaml;C:\Users\pad\AppData\Local\opam.14.1+mingw64\lib/stublibs'; export CAML_LD
_LIBRARY_PATH;
OCAML_TOPLEVEL_PATH='C:\Users\pad\AppData\Local\opam\4.14.1+mingw64\lib\toplevel'; export OCAML_TOPLEVEL_PATH;
MANPATH='"C:\Users\pad\AppData\Local\opam\4.14.1+mingw64\man":"C:\Users\pad\AppData\Local\opam\4.14.1+mingw64\man"'; export MANPATH;
PATH='/cygdrive/c/Users/pad/AppData/Local/opam/4.14.1+mingw64/bin:/usr/local/bin:/usr/bin:/cygdrive/c/ProgramData/Oracle/Java/javapath:/cygd
rive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/WINDOWS/System32/WindowsPowerShell/v1.0:/cygdrive/
c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/WINDOWS/System32/WindowsPowerShell/v1.0:/cygdrive/c/WIN
DOWS/System32/OpenSSH:/cygdrive/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/cygdrive/c/Users/pad/AppData/Local/Microsoft/WindowsA
pps'; export PATH;


@aryx
Copy link
Author

aryx commented Nov 15, 2023

(BTW why CC=x86_64_w64-mingw32 when I asked to install 4.14.1+mingw64? )

@kit-ty-kate
Copy link
Member

mmh, and where is pkg-config located? command -v pkg-config

(BTW why CC=x86_64_w64-mingw32 when I asked to install 4.14.1+mingw64? )

the same reason Win32 is still a name used by Windows even on x86_64 systems. It’s just the name for the x86_64 mingw compiler ^^

@aryx
Copy link
Author

aryx commented Nov 15, 2023

$ command -v pkg-config
/usr/bin/pkg-config

@aryx
Copy link
Author

aryx commented Nov 16, 2023

Maybe you need to imitate https://fdopen.github.io/opam-repository-mingw/depext-cygwin/ ?

@aryx
Copy link
Author

aryx commented Nov 16, 2023

BTW with the opam64 from fdopen, I can install it without problem:

$ opam install conf-libpcre
The following actions will be performed:
  ∗ install conf-pkg-config 2 [required by conf-libpcre]
  ∗ install conf-libpcre    1
===== ∗ 2 =====
Do you want to continue? [Y/n]

<><> Gathering sources ><><><><><><><><><><><><><><><><><><><><><><><><><><><><>

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
∗ installed conf-pkg-config.2
∗ installed conf-libpcre.1
Done.
# Run eval $(opam env) to update the current shell environment

pad@xayr ~
$

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants