From: Alain Frisch <alain@frisch.fr>
To: John Whitington <john@coherentgraphics.co.uk>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Building with OCamlMkLib
Date: Tue, 20 Jan 2009 18:22:34 +0100 [thread overview]
Message-ID: <4976085A.4010806@frisch.fr> (raw)
In-Reply-To: <B6E31133-DB91-4453-BC16-70A3840E8E7A@coherentgraphics.co.uk>
John Whitington wrote:
> Hi Folks,
>
> 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 used some test files (included below) in place of the real ones.
>
> I can successfully build the library (I'm using OS x / intel):
>
> ocamlc -c -cc "cc" -ccopt " -DNATIVE_CODE -o cpdflibwrapper.o"
> cpdflibwrapper.c
> ocamlc cpdflibc.mli
> ocamlc cpdflibc.ml
> ocamlmklib -o camlpdfc cpdflibc.ml cpdflibwrapper.a
>
> (builds dllcamlpdfc.so, camlpdfc.a, camlpdfc.cma, camlpdfc.cmxa)
>
> But trying to link a C program which uses the new library fails. Do I
> need to include something else, or have I got the ocamlmklib stage wrong?
You need to include an OCaml "main program" into your library. The
easiest way to build a library that include the OCaml runtime, some
OCaml code and custom C code is the -output-obj option:
ocamlc -output-obj -o camlpdfc.so cpdlibc.cmo cpdflibwrapper.o
Note that cpdflibrwrapper should define a function that calls
caml_startup in order to start the OCaml runtime and run the OCaml code.
If you want to build a static library, you can use "-output-obj -o
camlpdf.o" and then create the library yourself.
-- Alain
next prev parent reply other threads:[~2009-01-20 17:22 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 ` Alain Frisch [this message]
2009-01-20 21:35 ` [Caml-list] " Matthieu Dubuget
2009-01-21 14:43 ` Stefano Zacchiroli
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=4976085A.4010806@frisch.fr \
--to=alain@frisch.fr \
--cc=caml-list@yquem.inria.fr \
--cc=john@coherentgraphics.co.uk \
/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;
as well as URLs for NNTP newsgroup(s).