Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Question in Linking C and Ocaml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2003-07-02 (21:48)
From: Jung Woon Ho <unosoft@h...>
Subject: [Caml-list] Question in Linking C and Ocaml
Im trying to link some Ocaml files to my C program. And I'm having 
difficulties in liking them together.
here is what I do....

1)  compile all my Ocaml src code with the following command.
ocamlopt -c -output-obj  <filenames>
2) compile my C file using GCC (obtain object files)
3) compile my C file that calls the OCAML function with ocamlc -c (obtain 
object files)
     ar -rv sched.a mod.a and all the object files produced above. (obtain 
4) ranlib sched.a
5) finally in the main Makefile when I try to link the sched.a (produced 
above) using
g++ -L/usr/include -O3 -DHAVE_CONFIG_H  myfiles.o sched/sched.a -lncurses 
-lm -ldl

Gives me the following errors:

sched/sched.a(modwrap.o)(.text+0x27): In function `fib':
: undefined reference to `caml_named_value'
sched/sched.a(modwrap.o)(.text+0x42): In function `fib':
: undefined reference to `copy_string'
sched/sched.a(modwrap.o)(.text+0x53): In function `fib':
: undefined reference to `callback'
sched/sched.a(modwrap.o)(.text+0x88): In function `format_result':
: undefined reference to `caml_named_value'
sched/sched.a(modwrap.o)(.text+0xab): In function `format_result':
: undefined reference to `callback'
collect2: ld returned 1 exit status

I tried different variations of what I explainded above and I cant get it to 
link together.
Can somebody help me with this?

This is my second day stuck with this problem, any kind of help will be 
greatly apreciated.
thank you very much.

MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*.

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: