From: Aaron Bohannon <bohannon@cis.upenn.edu>
To: caml-list@yquem.inria.fr
Subject: compiling C library wrapper
Date: Thu, 5 Nov 2009 17:32:14 -0500 [thread overview]
Message-ID: <c413fcb70911051432l5d28918cq55b95272efb6330@mail.gmail.com> (raw)
Hi,
I am quite confused by the whole process of compiling and installing
wrappers for C libraries. It seems like I can get things to work OK
without really knowing what I'm doing if everything is put and built
in a single directory. The hard part seems to be putting the right
files in the right places and getting the path arguments correct.
Then things stop working, and I have to really understand what's going
on, but the manual doesn't explain this part of the process in any
detail.
Let's say I have a library "/opt/local/lib/libfoo.a" for which I want
to build and use a (native-code) OCaml wrapper. Here are the steps as
I understand them:
1) Write the file "foo_stubs.c" and compile it to get "foo_stubs.o".
2) Build the library "libfoo_stubs.a" by running
ar rc libfoo_stubs.a foo_stubs.o
3) Copy "libfoo_stubs.a" to its permanent location, let's say,
"/usr/local/lib/ocaml/stubs/libfoo_stubs.a".
4) Write "foo.mli" and use it to build "foo.cmi"
5) Write "foo.ml" and use it to build "foo.cmxa" by running
ocamlopt -a -o foo.cmxa foo.ml
-ccopt -L/opt/local/lib -cclib -lfoo
-ccopt -L/usr/local/lib/ocaml/stubs -cclib -lfoo_stubs
6) Copy "foo.cmi" and "foo.cmxa" to their permanent location, let's
say "/usr/local/lib/ocaml/foo/"
7) Write my file "bar.ml" that needs to use the library, and compile
it by running
ocamlopt -I /usr/local/lib/ocaml/foo -o bar foo.cmxa bar.ml
However, this command ends up passing gcc the filename
/usr/local/lib/ocaml/foo/foo.a
which doesn't exist, so I get an error. Where did this filename come
from? Where did I go wrong?
- Aaron
next reply other threads:[~2009-11-05 22:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-05 22:32 Aaron Bohannon [this message]
2009-11-05 23:09 ` [Caml-list] " David Allsopp
2009-11-05 23:38 ` Aaron Bohannon
2009-11-07 12:25 ` Richard Jones
2009-11-07 16:34 ` Aaron Bohannon
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=c413fcb70911051432l5d28918cq55b95272efb6330@mail.gmail.com \
--to=bohannon@cis.upenn.edu \
--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