Document Tree | ||
|
NAVIGATION How to...
Contact |
A stub library (and a bit more) for the ODBC[1] interface is provided by Maxence Guesdon and can be downloaded here. Unfortunately, the distributed makefile does neither support dynamic libraries nor the installation as findlib package. The following text shows how to do that. It applies to version 2.5 of ocamlodbc, but only to the unixodbc option. (For the other supported types of DB connections the following is probably not fully incorrect, but simply not exactly matching.) First, configure and build as described in the README: ./configure make unixodbcNow we will improve the result of the build process. First, we recompile ocaml_odbc_c.c for usage in a shared library: ocamlc -c -ccopt -pthread -ccopt '-D unixODBC' -I `ocamlc -where`/caml \ -verbose ocaml_odbc_c.cNote that I have copied the options "-pthread" and "-D unixODBC" from the original build process. Now create the libraries: ocamlmklib -verbose -o ocamlodbc ocaml_odbc.cmo ocamlodbc.cmo \ ocaml_odbc.cmx ocamlodbc.cmx ocaml_odbc_c.o -lodbcThis should generate dllocamlodbc.so, libocamlodbc.a, ocamlodbc.cma, ocamlodbc.cmxa, and ocamlodbc.a. Previous versions of these files are overwritten. Copy everything to the directory unixodbc: cp dllocamlodbc.so libocamlodbc.a ocamlodbc.mli ocamlodbc.cma / ocamlodbc.cmxa ocamlodbc.a ocamlodbc.cmi ocaml_odbc.cmi unixodbc/Go into this directory, create a META file, and install the package: cd unixodbc cat <<EOF >META > version = "2.5" > description = "Database interface with ODBC" > archive(byte) = "ocamlodbc.cma" > archive(native) = "ocamlodbc.cmxa" > EOF ocamlfind install ocamlodbc *Now test if everything has worked: $ ocaml Objective Caml version 3.06 # #use "topfind";; Findlib has been successfully loaded. Additional directives: #require "package";; to load a package #list;; to list the available packages #camlp4o;; to load camlp4 (standard syntax) #camlp4r;; to load camlp4 (revised syntax) Topfind.reset();; to force that packages will be reloaded - : unit = () # #require "ocamlodbc";; Loading /opt/ocaml-3.06/site-lib/ocamlodbc/ocamlodbc.cma # module M = Ocamlodbc;; module M : (omitted) #If you get errors, something went wrong.
|