From: Stefano Zacchiroli <zack@upsilon.cc>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Building with OCamlMkLib
Date: Wed, 21 Jan 2009 15:43:03 +0100 [thread overview]
Message-ID: <20090121144303.GA20353@usha.takhisis.invalid> (raw)
In-Reply-To: <B6E31133-DB91-4453-BC16-70A3840E8E7A@coherentgraphics.co.uk>
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
next prev parent reply other threads:[~2009-01-21 14:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-20 17:03 John Whitington
2009-01-20 17:22 ` [Caml-list] " Alain Frisch
2009-01-20 21:35 ` Matthieu Dubuget
2009-01-21 14:43 ` Stefano Zacchiroli [this message]
2009-01-22 15:21 ` John Whitington
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090121144303.GA20353@usha.takhisis.invalid \
--to=zack@upsilon.cc \
--cc=caml-list@yquem.inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox