Version française
Home     About     Download     Resources     Contact us    
Browse thread
ocamlc linking with .dll
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Matthieu Dubuget <matthieu.dubuget@g...>
Subject: ocamlc linking with .dll
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