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.0 required=5.0 tests=none 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 ABC56BBAF for ; Tue, 20 Jan 2009 18:03:59 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AoUJAA2TdUnD2MUqXWdsb2JhbACTfSMht1eFcw X-IronPort-AV: E=Sophos;i="4.37,295,1231110000"; d="scan'208";a="19909229" Received: from bluelynx4.ukhost4u.com ([195.216.197.42]) by mail2-smtp-roc.national.inria.fr with ESMTP; 20 Jan 2009 18:03:59 +0100 Received: from [94.194.70.78] (helo=feast.lan) by bluelynx4.ukhost4u.com with esmtpa (Exim 4.69) (envelope-from ) id 1LPK18-0007og-8a for caml-list@yquem.inria.fr; Tue, 20 Jan 2009 17:03:58 +0000 Message-Id: From: John Whitington To: caml-list@yquem.inria.fr Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v930.3) Subject: Building with OCamlMkLib Date: Tue, 20 Jan 2009 17:03:55 +0000 X-Mailer: Apple Mail (2.930.3) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bluelynx4.ukhost4u.com X-AntiAbuse: Original Domain - yquem.inria.fr X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - coherentgraphics.co.uk X-Source: X-Source-Args: X-Source-Dir: X-Spam: no; 0.00; ocamlmklib:01 ocamlmklib:01 ocaml:01 ocamlc:01 -dnative:01 ocamlc:01 mli:01 cmxa:01 gcc:01 usr:01 lib:01 ocaml:01 libasmrun:01 libasmrun:01 intern:01 Hi Folks, 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 used some test files (included below) in place of the real ones. I can successfully build the library (I'm using OS x / intel): ocamlc -c -cc "cc" -ccopt " -DNATIVE_CODE -o cpdflibwrapper.o" cpdflibwrapper.c ocamlc cpdflibc.mli ocamlc cpdflibc.ml ocamlmklib -o camlpdfc cpdflibc.ml cpdflibwrapper.a (builds dllcamlpdfc.so, camlpdfc.a, camlpdfc.cma, camlpdfc.cmxa) But trying to link a C program which uses the new library fails. Do I need to include something else, or have I got the ocamlmklib stage wrong? feast:trunk john$ gcc test.c -o test_executable -L. -L/usr/local/lib/ ocaml -lcamlpdfc -lasmrun Undefined symbols: "_caml_code_area_end", referenced from: _caml_code_area_end$non_lazy_ptr in libasmrun.a(signals_asm.o) _caml_code_area_end$non_lazy_ptr in libasmrun.a(intern.o) _caml_code_area_end$non_lazy_ptr in libasmrun.a(extern.o) "_caml_program", referenced from: _caml_start_program in libasmrun.a(i386.o) "_caml_bucket_Out_of_memory", referenced from: _caml_bucket_Out_of_memory$non_lazy_ptr in libasmrun.a(fail.o) (many more lines) Here are the input files forming the mixed ocaml/c library: (* cpdflibc.mli *) val twice : int -> int (* cpdflibc.ml *) let twice x = x * 2 /* cpdflibwrapper.h */ int twice (int); /* cpdflibwrapper.c */ #include #include #include int twice_c (int i) { CAMLlocal1 (result); result = caml_callback(*caml_named_value("twice"), Val_int(i)); return(0); } And here's the C program which will be using the libary: /* test.c */ #include #include "cpdflibwrapper.h" int main () { printf("Twice two is %i\n", twice_c(2)); return(0); } Here's a zip containing those files: http://www.coherentpdf.com/files.zip Any ideas? -- John Whitington Coherent Graphics Ltd http://www.coherentpdf.com/