Search code examples
windowsdllocamlllvm

Can you compile an OCaml project natively as a windows library?


I am new to OCaml (but I have used SML in the past) and I want to know two things:
1- Can OCaml programs be compiled as libraries at all?
2- If so, can they be compiled as native Windows dlls.

What I want to do is create an compiler library in OCaml using LLVM and use it from another Windows program.

PS: I know I can use LLVM from C++ and C, but I prefer OCaml since I am doing it for fun.


Solution

  • Yes, see ocamlopt -output-obj option and chapter 18.7.5 Embedding the Caml code in the C code of the manual.