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 AE357BBAF for ; Thu, 5 Nov 2009 23:32:16 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: An0BAGvh8krRVd7JkGdsb2JhbACQEoQYhwY/AQEBAQkJDAcTA7VsMoVZI4hFAQMDBYQ4BIoR X-IronPort-AV: E=Sophos;i="4.44,688,1249250400"; d="scan'208";a="36254086" Received: from mail-pz0-f201.google.com ([209.85.222.201]) by mail2-smtp-roc.national.inria.fr with ESMTP; 05 Nov 2009 23:32:15 +0100 Received: by pzk39 with SMTP id 39so283489pzk.15 for ; Thu, 05 Nov 2009 14:32:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:date :x-google-sender-auth:message-id:subject:from:to:content-type; bh=yz/zm/dFInasKuALj0GJ9GkBbDaTdBGfh9yxnAQg6Tw=; b=Yju7KPvk7vgp8kAdP1GALbsFny8LLUNSKsV5wjwls2H0LwE9QZBr1eXcdYkE/g8mye vMmUGQugJA+n21GMTRhV1Fo6o8XVpLvqgpt7GzhkpShvdPSopgsR8K7fCzsaAWnNlY0O TLujVUvX4xHawvRL4zEu5+4XgQbdIgbrXocmU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:content-type; b=Wam5RUd7VIvg7IMHWaU86Atlz5M548yH3lqFaH2JpqSQT2wLnRSLrFuNHMvShNb5hr xmV0+batJ2mmCUQT5KF21Or/lDFPqhvY1jrAT57l1ebi+muJwL2XyXFbb20Y3KZVjoPV 8csf+dJE5BjM0LrBBQsAmjZEvn4ILARemQj/4= MIME-Version: 1.0 Sender: aaron678@gmail.com Received: by 10.142.9.37 with SMTP id 37mr385079wfi.116.1257460334830; Thu, 05 Nov 2009 14:32:14 -0800 (PST) Date: Thu, 5 Nov 2009 17:32:14 -0500 X-Google-Sender-Auth: 36965b94f7599897 Message-ID: Subject: compiling C library wrapper From: Aaron Bohannon To: caml-list@yquem.inria.fr Content-Type: text/plain; charset=ISO-8859-1 X-Spam: no; 0.00; wrappers:01 lib:01 libfoo:01 native-code:01 ocaml:01 foo:01 stubs:01 foo:01 stubs:01 libfoo:01 usr:01 lib:01 ocaml:01 mli:01 cmi:01 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