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] ocamlmklib on Windows
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2003-07-17 (20:38)
From: Xavier Leroy <xavier.leroy@i...>
Subject: Re: [Caml-list] ocamlmklib on Windows
> Has anyone successfully compiled ocamlmklib on Windows? I'd like to
> build a Windows native port of camlimages, but lack of this program in
> the basic distribution is stopping me.

There's a mismatch between the ocamlmklib approach and Windows DLLs
that has prevented me so far from making the former work with the

Basically, ocamlmklib assumes that, from the *same* set of object C
files, one can build both
- a static library that can be statically linked with the Caml runtime system
  and the application, and
- a shared library (DLL) that can be dynamically linked with the Caml
  runtime system and the application.

This does *not* appear to be the case for Windows.  Namely, a static
lib that accesses a global variable defined in the Caml runtime system
does this directly, while a DLL must do it through one additional
indirection.  Thus, the code for the library must be compiled differently
(using / not using "__declspec(dllimport)" specifiers) depending on
whether it is to be put in a static library or in a DLL.  With the
Mingw toolchain, it seems possible to generate code that works in both
contexts, but I was unable to do this with the MSVC toolchain.

So, no ocamlmklib under Windows.  Still, you can look at some of the
Win32 makefiles in the OCaml source distribution for examples of how
to build mixed C/Caml libraries under Windows.  (Look at
otherlibs/win32unix/Makefile.nt for instance.)

- Xavier Leroy

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