I am writing a OCaml program but want to call some C functions provided in some source code or library.
How to achieve this? Is there any good tutorials on this?
A comprehensive reference manual: Chapter 19 Interfacing C with OCaml.
One example that calls a system call from OCaml: Calling Unix libraries from OCaml.
An example is as follows.
open Unix;; print_string "My pid: ";; print_int (getpid ());; print_newline ();; print_newline ();; print_string "ls / -l";; print_newline ();; system "ls / -l";;
To run it:
ocaml unix.cma UseUnix.ml