From: Julien Moutinho <julien.moutinho@gmail.com>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] OCaml/C interface
Date: Fri, 26 Oct 2007 11:18:06 +0200 [thread overview]
Message-ID: <20071026091806.GA10054@localhost> (raw)
In-Reply-To: <ab0c618e0710251517p3ab42e64m64dbe7c886193f5e@mail.gmail.com>
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.
next prev parent reply other threads:[~2007-10-26 9:17 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-25 22:17 Nathan Mishra Linger
2007-10-26 9:18 ` Julien Moutinho [this message]
2007-10-26 18:13 ` [Caml-list] " Nathan Mishra Linger
2007-10-28 12:36 ` David Teller
2007-10-28 13:34 ` skaller
2007-10-28 13:48 ` Christopher L Conway
2007-10-28 15:39 ` David Teller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20071026091806.GA10054@localhost \
--to=julien.moutinho@gmail.com \
--cc=caml-list@yquem.inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox