caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* compiling C library wrapper
@ 2009-11-05 22:32 Aaron Bohannon
  2009-11-05 23:09 ` [Caml-list] " David Allsopp
  0 siblings, 1 reply; 5+ messages in thread
From: Aaron Bohannon @ 2009-11-05 22:32 UTC (permalink / raw)
  To: caml-list

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-11-07 16:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-05 22:32 compiling C library wrapper Aaron Bohannon
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

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).