Kaleidoscope Build Problems - (OCaml)

Hello everyone…

I’m hoping that someone can give me insight as to why I am having problems building the Kaleidoscope example for OCaml.

Platform: Mac OS 10.8.2
OCaml version: 4.00.1
LLVM version: 3.1
XCode version: 4.5.2

I successfully build the examples when running “gnumake BUILD_EXAMPLES=1” in the OBJ_DIR, however when I try to build them from outside the build tree (ie move the source into my own subtree), I run into problems.

When I try to build (ocamlbuild toy.byte) after moving the llvm_* .cma, .cmo. .cmx .cmxa and .a into the local directory, I get the following error.

  • /usr/local/bin/ocamlc.opt llvm.cma llvm_analysis.cma llvm_executionengine.cma llvm_target.cma llvm_scalar_opts.cma -cc clang++ ast.cmo token.cmo parser.cmo codegen.cmo lexer.cmo toplevel.cmo toy.cmo bindings.o -o toy.byte
    clang: warning: treating ‘c’ input as ‘c++’ when in C++ mode, this behavior is deprecated
    ld: library not found for -lllvm_scalar_opts
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    File “none”, line 1:
    Error: Error while building custom runtime system
    Command exited with code 2.

I noticed that the make files provided do not use myocamlbuild.ml (and hence the ocamlbuild tool), but quite frankly, I find it difficult to follow exactly how they find the library files required in the OBJ_DIR tree to do the build.

Any explicit attempt to include library paths gives me the following error.

ocamlbuild -I /usr/local/bin toy.byte

Failure:
Included or excluded directories must be implicit (not “/usr/local/bin”).
Compilation unsuccessful after building 0 targets (0 cached) in 00:00:00.

Any suggestions would be greatly appreciated.

Cheers,
Frank