Windows下使用OPAM编译OCaml时出现'-lws2_32'文件找不到错误
Windows下OCaml环境搭建编译失败问题
我正按照官方教程在Windows上搭建OCaml环境,但编译过程失败,错误信息如下:
[ERROR] The compilation of ocaml-base-compiler.5.2.1 failed at "make -j7". #=== ERROR while compiling ocaml-base-compiler.5.2.1 ==========================# # context 2.3.0 | win32/x86_64 | | https://opam.ocaml.org#9f34991c038ca38ca54a43232b9cae1c14a3f1e3 # path ~\AppData\Local\opam\default\.opam-switch\build\ocaml-base-compiler.5.2.1 # command ~\AppData\Local\opam\.cygwin\root\bin\make.exe -j7 # exit-code 2 # env-file ~\AppData\Local\Temp\opam-axele-22540\ocaml-base-compiler-22540-ab1bc1.env # output-file ~\AppData\Local\Temp\opam-axele-22540\ocaml-base-compiler-22540-ab1bc1.out ### output ### # cp flexdll-sources/flexdll_mingw64.o flexdll-sources/flexdll_initer_mingw64.o byte/bin # [...] # ** Fatal error: Cannot find file "-lws2_32" # make[2]: *** [Makefile:1309: runtime/ocamlrun.exe] Error 2 # make[2]: *** Waiting for unfinished jobs.... # ** Fatal error: Cannot find file "-lws2_32" # make[2]: *** [Makefile:1321: runtime/ocamlrund.exe] Error 2 # ** Fatal error: Cannot find file "-lws2_32" # make[2]: *** [Makefile:1327: runtime/ocamlruni.exe] Error 2 # make[2]: Leaving directory '/cygdrive/c/Users/axele/AppData/Local/opam/default/.opam-switch/build/ocaml-base-compiler.5.2.1' # make[1]: *** [Makefile:750: opt.opt] Error 2 # make[1]: Leaving directory '/cygdrive/c/Users/axele/AppData/Local/opam/default/.opam-switch/build/ocaml-base-compiler.5.2.1' # make: *** [Makefile:831: world.opt] Error 2
我尝试过以下操作,但问题未解决:
- 安装更早版本:
opam switch create ocaml-base-compiler 5.2.0,仍出现相同错误 - 删除
~\AppData\Local下的opam文件夹,重新执行opam init -y
编辑 - 解决方案
已作为答案发布
内容的提问来源于stack exchange,提问作者overflowed-axel
相关产品推荐
相关产品推荐

