Browse thread
Building with OCamlMkLib
-
John Whitington
- Alain Frisch
- Matthieu Dubuget
- Stefano Zacchiroli
- John Whitington
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2009-01-21 (14:43) |
From: | Stefano Zacchiroli <zack@u...> |
Subject: | Re: [Caml-list] Building with OCamlMkLib |
On Tue, Jan 20, 2009 at 05:03:55PM +0000, John Whitington wrote: > I'm building a Plain C interface to our PDF libraries, but am > stuck. The idea is to build a library with Ocamlmklib containing the > C wrapper around the ocaml code. I've been working on a similar task these days. As Alain pointed out you were missing the -output-obj step. The actual rules I'm using to build the (static) library which is my current output are something like the following (Makefile excerpt): libcudf.a: cudf-caml.o cudf.o cp $(OCAML_LIBDIR)/libcamlrun.a $@ ar r $@ $^ cudf-caml.o: ../_build/cudf.cma ../_build/cudf_c.cmo ocamlfind ocamlc -linkpkg -output-obj -o $@ $^ where the stuff coming from _build/ is the output of the OCaml-only part of the library, and libcudf.a is the final C library to be delivered to C programmers. The real code from which this comes from is available at [1]. Note that the C programmers will then need to link in a peculiar way, here are my current instructions for them: cc -o test test.c `pkg-config --cflags cudf` `pkg-config --cflags cudf` Which expands to something schematic like: cc -o test test.c <INCLUDE PATHS> <LIB PATHS> -lcudf -lm -ldl -lunix -lncurses <OTHER -l FOR EXTERNAL LIBS> The glitch here is that test.c, which contains the invocation to caml_startup, must appear *before* -lcamlrun, as AFAICT it needs to override the main() defined there. If you try to put it at the end of the linking line, linking will fail. Cheers. [1] http://gforge.info.ucl.ac.be/plugins/scmsvn/viewcvs.php/trunk/updb/libcudf/c-lib/?root=mancoosi -- Stefano Zacchiroli -o- PhD in Computer Science \ PostDoc @ Univ. Paris 7 zack@{upsilon.cc,pps.jussieu.fr,debian.org} -<>- http://upsilon.cc/zack/ Dietro un grande uomo c'è ..| . |. Et ne m'en veux pas si je te tutoie sempre uno zaino ...........| ..: |.... Je dis tu à tous ceux que j'aime