[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Michael Hamburg <hamburg@f...> |
| Subject: | Re: [Caml-list] C linking on mingw |
I actually had a similar problem, and couldn't resolve it. I can link
gcc into ocamlopt, and i can link either way with ocamlc, but I can't
link ocaml code compiled with ocamlopt into a program whose main is in
C (actually, objective-C), for exactly the same reason.
Mike Hamburg
On May 17, 2004, at 12:31 PM, HENRIKSON, JEFFREY wrote:
> I am having trouble linking ocamlopt code with C via a dll on mingw.
> Here is a simple reproduction of the problem:
>
> Msgbox.c:
>
> #include <windows.h>
> #include <caml/mlvalues.h>
> #include <caml/memory.h>
>
> value c_msgbox(value i)
> {
> CAMLparam0();
> CAMLlocal1(s);
> s = alloc_string(15);
> MessageBox(NULL,"yay","hello",MB_OK);
> CAMLreturn (Val_int(0));
> }
>
>
> (Yes, the alloc_string doesn't do anything, it's only necessary to
> reproduce the situation. Suppose I have a real function that actually
> depends on the runtime.)
>
> gcc -mno-cygwin -I /cygdrive/c/ocaml/lib -I /usr/include/w32api -c
> msgbox.c
> gcc -mno-cygwin -shared /cygdrive/c/ocaml/lib/libasmrun.a msgbox.o -o
> msgbox.dll
>
> msgbox.o(.text+0x11):msgbox.c: undefined reference to `_local_roots'
> msgbox.o(.text+0x20):msgbox.c: undefined reference to `_local_roots'
> msgbox.o(.text+0x2b):msgbox.c: undefined reference to `_local_roots'
> msgbox.o(.text+0x52):msgbox.c: undefined reference to `_alloc_string'
> msgbox.o(.text+0x84):msgbox.c: undefined reference to `_local_roots'
> collect2: ld returned 1 exit status
>
>
> What makes this link? I am needing to do an ocamlopt program. The
> only
> file which resolves the linking above on my mingw distribution is
> ocamlrun.dll, which of course isn't meant for asm code linking.
> Specifically, it crashes before running a single line of code. I seem
> to remember there was an easy way to do this on the MS based port when
> I
> had it set up.
>
> PS: can someone please confirm/correct my understanding of these files:
> - ocamlrun.dll: the bytecode runtime.
> - ocamlrun.a: its import library.
> - libasmrun.a: the runtime for asm binary programs with entry point.
> - stdlib.a: utilities to support the Pervasives and standard libaries.
>
> Are there other related files? Must one have two separate code stub
> dlls for ocaml and ocamlopt?
>
> Thank you,
>
>
> Jeff Henrikson
>
> -------------------
> 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
>
-------------------
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