From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=AWL autolearn=disabled version=3.1.3 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 13109BBAF for ; Wed, 21 Jan 2009 15:43:29 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtIDAMHDdklDz4HegWdsb2JhbACTewEBFiK4N4Vz X-IronPort-AV: E=Sophos;i="4.37,300,1231110000"; d="scan'208";a="19956516" Received: from fettunta.fettunta.org ([67.207.129.222]) by mail2-smtp-roc.national.inria.fr with ESMTP; 21 Jan 2009 15:43:20 +0100 Received: from usha.takhisis.invalid (unknown [10.17.0.10]) by fettunta.fettunta.org (Postfix) with ESMTP id 03C341814D for ; Wed, 21 Jan 2009 14:43:20 +0000 (UTC) Received: by usha.takhisis.invalid (Postfix, from userid 1000) id 0CA1F609E; Wed, 21 Jan 2009 15:43:03 +0100 (CET) Date: Wed, 21 Jan 2009 15:43:03 +0100 From: Stefano Zacchiroli To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Building with OCamlMkLib Message-ID: <20090121144303.GA20353@usha.takhisis.invalid> References: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.18 (2008-05-17) X-Spam: no; 0.00; zacchiroli:01 zack:01 ocamlmklib:01 ocamlmklib:01 ocaml:01 -output-obj:01 makefile:01 ocaml:01 libdir:01 libcamlrun:01 cmo:01 ocamlfind:01 ocamlc:01 -linkpkg:01 -output-obj:01 On Tue, Jan 20, 2009 at 05:03:55PM +0000, John Whitington wrote: > I'm building a Plain C interface to our PDF libraries, but am > stuck. The idea is to build a library with Ocamlmklib containing the > C wrapper around the ocaml code. I've been working on a similar task these days. As Alain pointed out you were missing the -output-obj step. The actual rules I'm using to build the (static) library which is my current output are something like the following (Makefile excerpt): libcudf.a: cudf-caml.o cudf.o cp $(OCAML_LIBDIR)/libcamlrun.a $@ ar r $@ $^ cudf-caml.o: ../_build/cudf.cma ../_build/cudf_c.cmo ocamlfind ocamlc -linkpkg -output-obj -o $@ $^ where the stuff coming from _build/ is the output of the OCaml-only part of the library, and libcudf.a is the final C library to be delivered to C programmers. The real code from which this comes from is available at [1]. Note that the C programmers will then need to link in a peculiar way, here are my current instructions for them: cc -o test test.c `pkg-config --cflags cudf` `pkg-config --cflags cudf` Which expands to something schematic like: cc -o test test.c -lcudf -lm -ldl -lunix -lncurses The glitch here is that test.c, which contains the invocation to caml_startup, must appear *before* -lcamlrun, as AFAICT it needs to override the main() defined there. If you try to put it at the end of the linking line, linking will fail. Cheers. [1] http://gforge.info.ucl.ac.be/plugins/scmsvn/viewcvs.php/trunk/updb/libcudf/c-lib/?root=mancoosi -- Stefano Zacchiroli -o- PhD in Computer Science \ PostDoc @ Univ. Paris 7 zack@{upsilon.cc,pps.jussieu.fr,debian.org} -<>- http://upsilon.cc/zack/ Dietro un grande uomo c'è ..| . |. Et ne m'en veux pas si je te tutoie sempre uno zaino ...........| ..: |.... Je dis tu à tous ceux que j'aime