caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Aaron Bohannon <bohannon@cis.upenn.edu>
To: David Allsopp <dra-news@metastack.com>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] compiling C library wrapper
Date: Thu, 5 Nov 2009 18:38:05 -0500	[thread overview]
Message-ID: <c413fcb70911051538u479f3e50vff507353009a9851@mail.gmail.com> (raw)
In-Reply-To: <000001ca5e6d$0d6a0aa0$283e1fe0$@metastack.com>

Ah!  Yes, that's exactly the part I didn't understand and everything
works fine now.  Thank you!

I can't say I completely understand the byte-code case, but I don't
have an urgent need to.

ocamlmklib seems fine, but if it's just a matter of saving keystrokes,
"make" does a pretty good job of that (as long as I know what to tell
"make" to do).

 - Aaron

On Thu, Nov 5, 2009 at 6:09 PM, David Allsopp <dra-news@metastack.com> wrote:
> Aaron Bohannon wrote:
>> 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.
>
> Have a look at ocamlmklib in the manual - if it's available on your platform
> then it nicely hides away a lot of this.
>
> <snip - steps 1-4 are fine>
>> 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
>
> This command will also build foo.cmx, foo.a and foo.o
>
>> 6) Copy "foo.cmi" and "foo.cmxa" to their permanent location, let's
>> say "/usr/local/lib/ocaml/foo/"
>
> You should also copy foo.a to this directory which should fix the problem.
> foo.cmxa contains information required by OCaml but the actual code is in
> foo.a (as it's been natively compiled). Similarly, .cmx files contain
> information which ocamlopt needs but the actual code is in .o (or .obj)
> files. For native code, it's a code idea to copy the .cmx files too as it
> allows ocamlopt to do some inlining (I think that's right...)
>
>> 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
>
> This should now work without error.
>
>
> David
>
>
>


  reply	other threads:[~2009-11-05 23:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-05 22:32 Aaron Bohannon
2009-11-05 23:09 ` [Caml-list] " David Allsopp
2009-11-05 23:38   ` Aaron Bohannon [this message]
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=c413fcb70911051538u479f3e50vff507353009a9851@mail.gmail.com \
    --to=bohannon@cis.upenn.edu \
    --cc=caml-list@yquem.inria.fr \
    --cc=dra-news@metastack.com \
    /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).