From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 60116BBAF for ; Fri, 6 Nov 2009 00:38:07 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApABAKfw8krRVaAskmdsb2JhbACQEoQYhwY/AQEBAQkLCgcRtWgyhWEjiEUBAwMFgkGBdwSKEQ X-IronPort-AV: E=Sophos;i="4.44,688,1249250400"; d="scan'208";a="36256147" Received: from mail-pw0-f44.google.com ([209.85.160.44]) by mail2-smtp-roc.national.inria.fr with ESMTP; 06 Nov 2009 00:38:06 +0100 Received: by pwj15 with SMTP id 15so328898pwj.3 for ; Thu, 05 Nov 2009 15:38:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to:cc :content-type:content-transfer-encoding; bh=rgA7CrsyASpAb1udF2XwV87Z3ZOsKfuc6LQv+hom4gI=; b=oHFRnF2qyT1SQW5I9qAZBg/kCbxmCQYQ0AZ1aNsiULxQ0buo6Mnk8KdXoZ6KeHbxMS vHG8OlaQjPV9o5gl21E5YBvlROR7KUNMXU7LD8Hu1XziJ+Bkmf0z0dyGU11w5QBJQEil L3kvTIUFObRVz1TQD1vJ0em+ZZgkNuo2M/eh8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=ETeUI/IgPAuTnO08zDWS7rS6KBT/hg6lvzHtMG1O0Dk+yI2AJnn4CptY3ONOZN8job rfMYiKQN1mRPLknMpXfFjE7mOkXEF2p2bQYoPmH7wJxHgPCAfuF53z6Pk5f1LuFO9Hfe r2t2BzvxTeTwJmiv+eiPc4a7vRGj7zQEUltj4= MIME-Version: 1.0 Sender: aaron678@gmail.com Received: by 10.143.24.42 with SMTP id b42mr378766wfj.237.1257464285433; Thu, 05 Nov 2009 15:38:05 -0800 (PST) In-Reply-To: <000001ca5e6d$0d6a0aa0$283e1fe0$@metastack.com> References: <000001ca5e6d$0d6a0aa0$283e1fe0$@metastack.com> Date: Thu, 5 Nov 2009 18:38:05 -0500 X-Google-Sender-Auth: 130744894cd93156 Message-ID: Subject: Re: [Caml-list] compiling C library wrapper From: Aaron Bohannon To: David Allsopp Cc: caml-list@yquem.inria.fr Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam: no; 0.00; byte-code:01 ocamlmklib:01 wrappers:01 ocamlmklib:01 foo:01 foo:01 cmxa:01 ocamlopt:01 cmxa:01 lib:01 -cclib:01 usr:01 lib:01 ocaml:01 stubs:01 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 wrot= e: > Aaron Bohannon wrote: >> I am quite confused by the whole process of compiling and installing >> wrappers for C libraries. =A0It 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. =A0The 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 platf= orm > then it nicely hides away a lot of this. > > >> 5) Write "foo.ml" and use it to build "foo.cmxa" by running >> >> ocamlopt -a -o foo.cmxa foo.ml >> =A0 -ccopt -L/opt/local/lib -cclib -lfoo >> =A0 -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 > > >