简体   繁体   中英

Compiling ocaml with module Llvm_analysis

I'm working through chapter 3 of the tutorial of LLVM, The given file myocamlbuild.ml is:

open Ocamlbuild_plugin;;

ocaml_lib ~extern:true "llvm";;
ocaml_lib ~extern:true "llvm_analysis";;

flag ["link"; "ocaml"; "g++"] (S[A"-cc"; A"g++"]);;

But I find if I run

ocamlbuild -pkg llvm repl.byte

Error message is: the required module llvm_analysis is unavailable. What did I do wrong here? Thanks.

You've followed some outdated and probably wrong instructions. If you will install llvm from opam, it will be correctly packaged, and in order to use the llvm_analysis library, you just need to use -pkg llvm.analysis option of the ocamlbuild tool.

So, erase myocamlbuild.ml file, and any other support files, that you've created (eg, _tags ), and compile it as follows

 ocamlbuild -pkgs llvm,llvm.analysis repl.byte

or

 ocamlbuild -pkgs llvm,llvm.analysis repl.native

Add other llvm subpackages after the comma (no whitespaces).

To get the list of all llvm subpackages use the following command:

 ocamlfind list | grep llvm

See also my other answer to your previous questions for the detailed description on how to setup a new project, that uses llvm

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