caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Matthieu Dubuget <matthieu.dubuget@gmail.com>
To: caml-list@inria.fr
Subject: ocamlc linking with .dll
Date: Fri, 20 Mar 2009 13:34:44 +0100	[thread overview]
Message-ID: <49C38D64.1000200@gmail.com> (raw)

According to the manual,

for ocamlc:
> Arguments ending in .so (.dll under Windows) are assumed to be C
> shared libraries (DLLs).
> During linking, they are searched for external C functions referenced
> from the Caml code,
> and their names are written in the generated bytecode executable. The
> run-time system
> ocamlrun then loads them dynamically at program start-up time.

If I try:

>         $ ocamlc -custom -o m.exe ms_gates.native.dll m_stub.c m.ml
>         ** Cannot resolve symbols for m_stub.o:
>          _ms_gates_init
>          _ms_gates_version
>         File "m.ml", line 1, characters 0-1:
>         Error: Error while building custom runtime system


The dll is not passed to flexlink, as we can check with "-verbose":

>         $ ocamlc -custom -o m.exe -verbose ms_gates.native.dll
>         m_stub.c m.ml
>         + gcc -mno-cygwin -O -mms-bitfields -Wall -Wno-unused -c  
>         -I"C:/cygwin/home/matt/ocamlmgw/lib" "m_stub.c"
>         + flexlink -chain mingw -exe -o "m.exe"  
>         "-LC:/cygwin/home/matt/ocamlmgw/lib"
>         "c:\DOCUME~1\matt\LOCALS~1\Temp\camlprimec3406.c" "m_stub.o"
>         "-lcamlrun" -lws2_32
>         ** Cannot resolve symbols for m_stub.o:
>          _ms_gates_init
>          _ms_gates_version
>         File "m.ml", line 1, characters 0-1:
>         Error: Error while building custom runtime system


This is solved by adding -cclib in front of the dll name:


>         $ ocamlc -custom -o m.exe -verbose -cclib ms_gates.native.dll
>         m_stub.c m.ml
>         + gcc -mno-cygwin -O -mms-bitfields -Wall -Wno-unused -c  
>         -I"C:/cygwin/home/matt/ocamlmgw/lib" "m_stub.c"
>
>             + flexlink -chain mingw -exe -o "m.exe"  
>             "-LC:/cygwin/home/matt/ocamlmgw/lib"
>             "c:\DOCUME~1\matt\LOCALS~1\Temp\camlprimc0b326.c"
>             "ms_gates.native.dll" "m_stub.o" "-lcamlrun" -lws2_32
>

Is there a bug, either in the documentation or in ocamlc?

Salutations

Matt


             reply	other threads:[~2009-03-20 12:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-20 12:34 Matthieu Dubuget [this message]
2009-03-20 12:55 ` Matthieu Dubuget

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=49C38D64.1000200@gmail.com \
    --to=matthieu.dubuget@gmail.com \
    --cc=caml-list@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;
as well as URLs for NNTP newsgroup(s).