我使用opam install llvm
安装了llvm模块,并检查了库是否已正确创建。但是,当我尝试使用它时出现Error: Unbound module Llvm
错误。
a@prosseek Chapter3> ocaml llvm.cma
Cannot find file llvm.cma.
可能出现什么问题?
这是我在命令行中执行命令所得到的。
a@prosseek Chapter4> eval `opam config env`
a@prosseek Chapter4> opam install llvm
[NOTE] Package llvm is already installed (current version is 3.2).
a@prosseek Chapter4> ocaml
OCaml version 4.01.0
# #require "llvm";;
Unknown directive `require'.
# open Llvm;;
Error: Unbound module Llvm
来自http://projects.camlcity.org/projects/dl/findlib-1.3.1/doc/guide-html/quickstart.html。
# #use "topfind";;
- : unit = ()
Findlib has been successfully loaded. Additional directives:
#require "package";; to load a package
#list;; to list the available packages
#camlp4o;; to load camlp4 (standard syntax)
#camlp4r;; to load camlp4 (revised syntax)
#predicates "p,q,...";; to set these predicates
Topfind.reset();; to force that packages will be reloaded
#thread;; to enable threads
- : unit = ()
# #require "llvm";;
/Users/smcho/.opam/system/lib/llvm/.: added to search path
# #require "llvm";;system/lib/llvm/./llvm.cma: loaded
Error: The external function `llvm_global_succ' is not available
cd /Users/smcho/.opam/system/lib/llvm
a@prosseek llvm> ocamlfind ocamlmktop -o llvmtop -thread -linkpkg -package llvm llvm.cma -cc g++
File "llvm.cma(Llvm)", line 1:
Warning 31: files llvm.cma(Llvm) and /Users/smcho/.opam/system/lib/llvm/./llvm.cma(Llvm) both define a module named Llvm
a@prosseek llvm> llvmtop
OCaml version 4.01.0
# #use "topfind";;
to enable threads
- : unit = ()
# #require "llvm";;
/Users/smcho/.opam/system/lib/llvm/.: added to search path
/Users/smcho/.opam/system/lib/llvm/./llvm.cma: loaded
# open Llvm;;
但是,我不确定如何使用ocaml
,而不是llvmtop
。此网站包含有关上限循环的信息 - http://projects.camlcity.org/projects/dl/findlib-1.3.1/doc/guide-html/quickstart.html
答案 0 :(得分:0)
我对代码中的符号Chapter3>
感到困惑。你在哪里得到它?它是某种顶级的吗?将模块加载到顶层的一般过程是:
$ eval `opam config env`
$ opam install llvm
$ ocaml
# #use "topfind";;
# #require "llvm";;
# open Llvm;;
<强>更新强>
自定义顶层包含一些未加载到默认OCaml顶层的C函数。它们与之相关联。我想如果你向-verbose
调用添加ocamlfind
选项,你会看到一些特定于LLVM的链接选项。