2

我安装了 llvm 模块opam install llvm,并检查了库是否正确创建。但是,当我尝试使用它时,我得到了Error: Unbound module Llvm错误。

a@prosseek Chapter3> ocaml llvm.cma
Cannot find file llvm.cma. 

可能有什么问题?

编辑1

这是我在命令行中执行命令所得到的。

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

编辑2

来自llvm OCaml 绑定

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;;

但是,我不确定如何使它与 with 一起使用ocaml,而不是与llvmtop. 这个网站有关于顶级循环的信息 - http://projects.camlcity.org/projects/dl/findlib-1.3.1/doc/guide-html/quickstart.html

4

1 回答 1

0

我对Chapter3>您代码中的符号感到困惑。你在哪里得到它?它是某种顶级的吗?将模块加载到顶层的一般过程是:

$ eval `opam config env`
$ opam install llvm
$ ocaml
# #use "topfind";;
# #require "llvm";;
# open Llvm;;

更新 自定义顶层包含一些未加载到默认 OCaml 顶层的 C 函数。它们与它相连。我认为,如果您-verbose向调用添加选项,ocamlfind您将看到一些特定于 LLVM 的链接选项。

于 2014-01-03T07:45:57.373 回答