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=1.0 required=5.0 tests=AWL,HTML_MESSAGE,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 55EC6BC69 for ; Fri, 26 Oct 2007 20:13:44 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAAzLIUfRVca7mGdsb2JhbACCPTWLbwIBAQcEBhEW X-IronPort-AV: E=Sophos;i="4.21,334,1188770400"; d="scan'208";a="18663494" Received: from rv-out-0910.google.com ([209.85.198.187]) by mail4-smtp-sop.national.inria.fr with ESMTP; 26 Oct 2007 20:13:43 +0200 Received: by rv-out-0910.google.com with SMTP id k20so829045rvb for ; Fri, 26 Oct 2007 11:13:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; bh=ba7MWca+VV+Ia620Sw4Rk0z4j1qpB7YnR5imrVjluSw=; b=hNfen7wsWhC8K3yU+IdiERPnesLXFFstLpFBJOldccTOWx5j+OpNDmoLbeQnhpJfWEa/vVepT+2KL629lMQXAFXJUaZLaylqHndROf3VSmEDTPogyc6uGiDdO+qGHG1+bvubfmPuH8lXaQrvwDNdyUXmT1TETvNNGZzQ0H62rGU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=W711CBlEXTog+5kWoXWNiQM3Ib5NliZ8Qkh0rqDPMtji6k8iUTr8UYMTDKRUMWO5cgmUvaS2zCi6XrfhAq55AhBcFyR2JjTQDzjEQRiqePBL0ihognPkureajxVXHJjep2awKyJ/tNfj4MKbAEuItS5tHBU+J0kGdSH4lW4ZUp4= Received: by 10.141.63.20 with SMTP id q20mr1667090rvk.1193422422027; Fri, 26 Oct 2007 11:13:42 -0700 (PDT) Received: by 10.140.225.18 with HTTP; Fri, 26 Oct 2007 11:13:42 -0700 (PDT) Message-ID: Date: Fri, 26 Oct 2007 11:13:42 -0700 From: "Nathan Mishra Linger" To: "Julien Moutinho" Subject: Re: [Caml-list] OCaml/C interface Cc: caml-list@yquem.inria.fr In-Reply-To: <20071026091806.GA10054@localhost> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_3242_30292995.1193422422024" References: <20071026091806.GA10054@localhost> X-Spam: no; 0.00; ocaml:01 interfacing:01 ocaml:01 powerpc:01 makefile:01 makefile:01 myprog:01 usr:01 lib:01 -lcamlrun:01 myprog:01 usr:01 lib:01 -lcamlrun:01 -lm:01 ------=_Part_3242_30292995.1193422422024 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On 10/26/07, Julien Moutinho wrote: > > On Thu, Oct 25, 2007 at 03:17:43PM -0700, Nathan Mishra Linger wrote: > > Having just read Chapter 18 of the manual regarding "Interfacing C with > > OCaml", I wrote a simple program to test my understanding. However, > when I > > try to compile it I run into some undefined symbol problems (_tgetent, > > _tgetnum, etc). My machine is a PowerPC iBook G4 running OS X 10.4.10. > > > > Does anyone know how to fix this? After Googling around, I think this > is a > > Mac problem rather than an OCaml one, but I thought people on this list > > might have come up against this same problem. Also, any comments on my > C > > code that calls OCaml would be appreciated. > > A solution may be: > > % ls > Makefile Makefile.old test.c test.c.old test.ml > > % diff -U 0 Makefile.old Makefile > --- Makefile.old 2007-10-26 11:07:41.000000000 +0200 > +++ Makefile 2007-10-26 11:11:34.000000000 +0200 > @@ -5 +5 @@ > - cc -o myprog test.o camlcode.o -L/usr/local/lib/ocaml -lcamlrun > + cc -o myprog test.o camlcode.o -L/usr/local/lib/ocaml -lcamlrun > -lm -lcurses > > % diff -u test.c.old test.c > --- test.c.old 2007-10-26 11:06:33.000000000 +0200 > +++ test.c 2007-10-26 11:02:42.000000000 +0200 > @@ -25,9 +25,10 @@ > int main() { > CAMLlocal1(xs); > char* argv[] = {"yo"}; > - caml_main(argv); > + caml_startup(argv); > xs = up_to(5); > gc(); > printf("sum of [1..5] = %i\n", sum(xs)); > + return EXIT_SUCCESS; > } > > % make > ocamlc -c test.ml > cc -I/usr/local/lib/ocaml -c test.c > ocamlc -output-obj -o camlcode.o test.cmo > cc -o myprog test.o camlcode.o -L/usr/local/lib/ocaml -lcamlrun -lm > -lcurses > > % ./myprog > sum of [1..5] = 15 > > HTH, > Julien. Yep. That did it. Thanks, Julien! Nathan ------=_Part_3242_30292995.1193422422024 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline
On 10/26/07, Julien Moutinho <julien.moutinho@gmail.com> wrote:
On Thu, Oct 25, 2007 at 03:17:43PM -0700, Nathan Mishra Linger wrote:
> Having just read Chapter 18 of the manual regarding "Interfacing C with
> OCaml", I wrote a simple program to test my understanding.  However, when I
> try to compile it I run into some undefined symbol problems (_tgetent,
> _tgetnum, etc).  My machine is a PowerPC iBook G4 running OS X 10.4.10.
>
> Does anyone know how to fix this?  After Googling around, I think this is a
> Mac problem rather than an OCaml one, but I thought people on this list
> might have come up against this same problem.  Also, any comments on my C
> code that calls OCaml would be appreciated.

A solution may be:

% ls
Makefile Makefile.old test.c test.c.old test.ml

% diff -U 0 Makefile.old Makefile
--- Makefile.old        2007-10-26 11:07:41.000000000 +0200
+++ Makefile    2007-10-26 11:11: 34.000000000 +0200
@@ -5 +5 @@
-       cc -o myprog test.o camlcode.o -L/usr/local/lib/ocaml -lcamlrun
+       cc -o myprog test.o camlcode.o -L/usr/local/lib/ocaml -lcamlrun -lm -lcurses

% diff -u test.c.old test.c
--- test.c.old  2007-10-26 11:06:33.000000000 +0200
+++ test.c      2007-10-26 11:02:42.000000000 +0200
@@ -25,9 +25,10 @@
int main() {
   CAMLlocal1(xs);
   char* argv[]  = {"yo"};
-  caml_main(argv);
+  caml_startup(argv);
   xs = up_to(5);
   gc();
   printf("sum of [1..5] = %i\n", sum(xs));
+  return EXIT_SUCCESS;
}

% make
ocamlc -c test.ml
cc -I/usr/local/lib/ocaml -c test.c
ocamlc -output-obj -o camlcode.o test.cmo
cc -o myprog test.o camlcode.o -L/usr/local/lib/ocaml -lcamlrun -lm -lcurses

% ./myprog
sum of [1..5] = 15

HTH,
  Julien.


Yep.  That did it.  Thanks, Julien!

Nathan

------=_Part_3242_30292995.1193422422024--