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 (e.g., _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