From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id WAA30838; Thu, 19 Jun 2003 22:25:37 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id WAA31292 for ; Thu, 19 Jun 2003 22:25:36 +0200 (MET DST) Received: from mail.speakeasy.net (mail15.speakeasy.net [216.254.0.215]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h5JKPZH23605 for ; Thu, 19 Jun 2003 22:25:35 +0200 (MET DST) Received: (qmail 8065 invoked from network); 19 Jun 2003 20:25:33 -0000 Received: from unknown (HELO apprentice.genxnet.com) ([64.81.145.152]) (envelope-sender ) by mail15.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 19 Jun 2003 20:25:33 -0000 Date: Thu, 19 Jun 2003 15:28:49 -0500 From: art yerkes To: "Jung Woon Ho" Cc: caml-list@inria.fr, unosoft@hotmail.com Subject: Re: [Caml-list] Interfacing C and Ocaml Message-Id: <20030619152849.7eae9e70.ayerkes@on-demand-tech.com> In-Reply-To: References: X-Mailer: Sylpheed version 0.8.11 (GTK+ 1.2.10; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; yerkes:01 ayerkes:01 caml-list:01 interfacing:01 jung:99 curses:01 libncurses:01 ocamlc:01 -output-obj:01 usr:01 libcamlrun:01 -lcurses:01 printf:01 sprintf:01 callback:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Thu, 19 Jun 2003 19:58:16 +0000 "Jung Woon Ho" wrote: See: http://lists.suse.com/archive/suse-linux-e/2001-Aug/0476.html It appears that the name of the curses library on Suse is libncurses. > Hi, Im trying to implement a simple program that interfaces C and Ocaml. > Here is what I do: > > ocamlc -custom -output-obj -o modcaml.o mod.ml > ocamlc -c modwrap.c > cp /usr/local/lib/ocaml/libcamlrun.a mod.a > ar r mod.a modcaml.o modwrap.o > cc -o prog main.c mod.a -lcurses > > and I get the error: > /usr/lib/gcc-lib/i486-suse-linux/3.2/../../../../i486-suse-linux/bin/ld: > cannot find -lcurses > collect2: ld returned 1 exit status > > I tried cc -o prog main.c mod.a -lcurses -ltermcap and cc -o prog main.c > mod.a -ltermcap but i cant get the program to link. > > Does anybody know how to solve this problem? > > Thank you very much. > > > > > ---------------------mod.ml------------------------------- > (* File mod.ml -- some ``useful'' Caml functions *) > > let rec fib n = if n < 2 then 1 else fib(n-1) + fib(n-2) > > let format_result n = Printf.sprintf "Result is: %d\n" n > > (* Export those two functions to C *) > > let _ = Callback.register "fib" fib > let _ = Callback.register "format_result" format_result > ---------------------------------------------------------- > > --------------------modwrap.c----------------------------- > /* File modwrap.c -- wrappers around the Caml functions */ > > #include > #include > #include > #include > > int fib(int n) > { > static value * fib_closure = NULL; > if (fib_closure == NULL) fib_closure = caml_named_value("fib"); > return Int_val(callback(*fib_closure, Val_int(n))); > } > > char * format_result(int n) > { > static value * format_result_closure = NULL; > if (format_result_closure == NULL) > format_result_closure = caml_named_value("format_result"); > return strdup(String_val(callback(*format_result_closure, Val_int(n)))); > /* We copy the C string returned by String_val to the C heap > so that it remains valid after garbage collection. */ > } > ---------------------------------------------------------- > > -------------------main.c--------------------------------- > /* File main.c -- a sample client for the Caml functions */ > > #include > > int main(int argc, char ** argv) > { > int result; > > /* Initialize Caml code */ > caml_startup(argv); > /* Do some computation */ > result = fib(10); > printf("fib(10) = %s\n", format_result(result)); > return 0; > } > ---------------------------------------------------------- > > _________________________________________________________________ > Help STOP SPAM with the new MSN 8 and get 2 months FREE* > http://join.msn.com/?page=features/junkmail > > ------------------- > To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr > Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners -- `No, you don't understand,' the Knight said, looking a little vexed. `That's what the name is called. The name really is "The Aged Aged Man."' -- Lewis Carroll ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners