caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "HENRIKSON, JEFFREY" <JEFHEN@SAFECO.com>
To: <caml-list@inria.fr>
Cc: <lists@lophty.com>
Subject: [Caml-list] C linking on mingw
Date: Mon, 17 May 2004 09:31:01 -0700	[thread overview]
Message-ID: <9410EC84C0872141B27A2726613EF45D02A52D2D@psmrdcex01.psm.pin.safeco.com> (raw)

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


             reply	other threads:[~2004-05-17 16:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-17 16:31 HENRIKSON, JEFFREY [this message]
2004-05-17 17:33 ` Michael Hamburg

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=9410EC84C0872141B27A2726613EF45D02A52D2D@psmrdcex01.psm.pin.safeco.com \
    --to=jefhen@safeco.com \
    --cc=caml-list@inria.fr \
    --cc=lists@lophty.com \
    /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;
as well as URLs for NNTP newsgroup(s).