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.2 required=5.0 tests=AWL,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 EFBA5BC69 for ; Fri, 26 Oct 2007 11:17:21 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAOhNIUdA6ba+mGdsb2JhbACOXgIBAQcCCAcg X-IronPort-AV: E=Sophos;i="4.21,332,1188770400"; d="scan'208";a="18644313" Received: from nf-out-0910.google.com ([64.233.182.190]) by mail4-smtp-sop.national.inria.fr with ESMTP; 26 Oct 2007 11:17:21 +0200 Received: by nf-out-0910.google.com with SMTP id e27so635651nfd for ; Fri, 26 Oct 2007 02:17:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:received:date:to:subject:message-id:references:mime-version:content-type:content-disposition:in-reply-to:user-agent:from; bh=X06WMZn6tYxoMOJOgeQBHXpH+GIJhgnGq1Pw4ZuOqyo=; b=dFuKX5YHxkQIZupcULMf4oFU4bfGm/UN7FHx/TY1gQB4pCmAGkH7pcjAzPt9pwsofv02bZsNYGdH0BPXD0Lh6A3Yl1wQHMC0DPUOw0zo/DPTLdEfC9RRPdZLypY08LW9KCpdkFbpn2yc2wMTmybhR5udnQMfknNAI709CZymSZ4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:date:to:subject:message-id:references:mime-version:content-type:content-disposition:in-reply-to:user-agent:from; b=TGrRWvFxyOvj5lXsq1BE+waUDOK8ukvbUPLJceFOq0/QhVhBIQhGZXiTLVEnxIhtG7fAYH2HdbRluVsHsn3+RnKGgMRZRr9DL0PbEKsbQEESZqlwPibtElslsQsseyWGlO6U1yL9gCxoX9PoBlqmcIPj7bBOdogEstk3TWdXaYw= Received: by 10.78.134.2 with SMTP id h2mr2069506hud.1193390241038; Fri, 26 Oct 2007 02:17:21 -0700 (PDT) Received: from localhost ( [82.122.96.203]) by mx.google.com with ESMTPS id k9sm4716212nfh.2007.10.26.02.17.17 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 26 Oct 2007 02:17:19 -0700 (PDT) Received: by localhost (sSMTP sendmail emulation); Fri, 26 Oct 2007 11:18:06 +0200 Date: Fri, 26 Oct 2007 11:18:06 +0200 To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] OCaml/C interface Message-ID: <20071026091806.GA10054@localhost> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.16 (2007-06-11) From: Julien Moutinho 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 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.