简体   繁体   中英

Unbound module llvm

I have been working through the LLVM Kaleidoscope Tutorial for OCaml. On the third part of the tutorial , I have navigated to the example code in the folder

OCaml-Kaleidoscope\\Chapter3

I am encountering an issue when compiling with

ocamlbuild toy.byte

on cygwin. This is the code given in the tutorial to compile.

The error I am getting is

''ocamlc.opt -c -o codegen.cmo codegen.ml
File "codegen.ml", line 5, characters 5-9:
Error: Unbound module Llvm
Exit code 2 while executing this command:
''ocamlc.opt -c -o codegen.cmo codegen.ml

I looked up some solutions to this issue. One solution I found was to use

ocamlbuild -use-ocamlfind toy.byte -package llvm

instead of

ocamlbuild toy.byte

However, when I tried that I received this error:

Failure: ocamlfind not found on path, but -no-ocamlfind not used.

To fix this I tried:

opam install ocamlfind

But ocamlfind is already installed.

Another solution I found was to use:

opam install llvm

This resulted in:

The following actions will be performed:
  - install llvm 3.7

=-=- Gathering sources =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

=-=- Processing actions -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[llvm: ./install.sh 3.7] Command started
[ERROR] The installation of llvm failed at "./install.sh 3.7 make
        C:\\cygwin64\\home\\setup\\.opam\\system
        C:\\cygwin64\\home\\setup\\.opam\\system\\lib".
[llvm: ocamlfind remove] Command started

#=== ERROR while installing llvm.3.7 ==========================================#
# opam-version         1.3.0~dev2 (d4f7e01216dbb44af4e7cc6539a1b0afa9be9d2c)
# os                   win32
# command              bash -c ./install.sh 3.7 make C:/cygwin64/home/setup/.opa                             m/system C:/cygwin64/home/setup/.opam/system/lib
# path                 C:\cygwin64\home\setup\.opam\system\build\llvm.3.7
# exit-code            2
# env-file             C:\cygwin64\home\setup\.opam\system\build\llvm.3.7\llvm-1                             0768-58c514.env
# stdout-file          C:\cygwin64\home\setup\.opam\system\build\llvm.3.7\llvm-1                             0768-58c514.out
# stderr-file          C:\cygwin64\home\setup\.opam\system\build\llvm.3.7\llvm-1                             0768-58c514.err
### stdout ###
# [...]
# config.status: executing bindings/ocaml/Makefile.ocaml commands
# make: Entering directory '/home/setup/.opam/system/build/llvm.3.7/build/bindin                             gs'
# llvm[0]: Constructing LLVMBuild project information.
# make[1]: Entering directory '/home/setup/.opam/system/build/llvm.3.7/build/bin                             dings/ocaml'
# make[2]: Entering directory '/home/setup/.opam/system/build/llvm.3.7/build/bin                             dings/ocaml/llvm'
# llvm[2]: Compiling llvm_ocaml.c for Release+Asserts build
# /home/setup/.opam/system/build/llvm.3.7/Makefile.rules:1536: recipe for target                              '/home/setup/.opam/system/build/llvm.3.7/build/bindings/ocaml/llvm/Release+Asse                             rts/llvm_ocaml.o' failed
# make[2]: Leaving directory '/home/setup/.opam/system/build/llvm.3.7/build/bind                             ings/ocaml/llvm'
# /home/setup/.opam/system/build/llvm.3.7/Makefile.rules:880: recipe for target                              'all' failed
# make[1]: Leaving directory '/home/setup/.opam/system/build/llvm.3.7/build/bind                             ings/ocaml'
# /home/setup/.opam/system/build/llvm.3.7/Makefile.rules:939: recipe for target                              'ocaml/.makeall' failed
# make: Leaving directory '/home/setup/.opam/system/build/llvm.3.7/build/binding                             s'
### stderr ###
# [...]
# configure: WARNING: dlopen() not found - disabling plugin support
# configure: WARNING: mmap() of a fixed address required but not supported
# configure: WARNING: mmap() of files required but not found
# configure: WARNING: --enable-bindings=ocaml specified, but OUnit 2 is not inst                             alled. Tests will not run
# + make -C bindings all SYSTEM_LLVM_CONFIG=llvm-config
# gcc.exe: error: /home/setup/.opam/system/build/llvm.3.7/bindings/ocaml/llvm/ll                             vm_ocaml.c: No such file or directory
# gcc.exe: fatal error: no input files
# compilation terminated.
# /usr/bin/rm: cannot remove '/home/setup/.opam/system/build/llvm.3.7/build/bind                             ings/ocaml/llvm/Release+Asserts/llvm_ocaml.d.tmp': No such file or directory
# make[2]: *** [/home/setup/.opam/system/build/llvm.3.7/build/bindings/ocaml/llv                             m/Release+Asserts/llvm_ocaml.o] Error 1
# make[1]: *** [all] Error 1
# make: *** [ocaml/.makeall] Error 2



=-=- Error report -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
The following actions failed
  - install llvm 3.7
No changes have been performed

=-=- llvm.3.7 troubleshooting -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
=> This package relies on external (system) dependencies that may be missing.
   `opam depext llvm.3.7' may help you find the correct installation for your
   system.

I am using version 3.8.0 of llvm and version 4.02.3 of OCaml from this link .

Am I on the right track? What do I need to do to fix this?

As I have answered in your question LLVM tutorial OCaml Compilation Assembler Error , your best way is not to use Windows.

OPAM is now usable in Cygwin OCaml or even in MinGW OCaml (using Cygwin opam binary) but packages in the OPAM repository are not tested in these environments. Just avoid them unless you are experienced with OCaml program development in Windows.

If you stick to Windows, then check the build at C:\\cygwin64\\home\\setup\\.opam\\system\\build\\llvm.3.7 . There should be stdout and stderr log files which can help to understand what happend.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM