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

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Xavier Leroy <xavier.leroy@i...>
Subject: Re: [Caml-list] linking problem with camlidl on windows
> I posted a question some days ago, but it was not very precise.
> I am trying to use one DLL from Ocaml with camlidl.
> Since I can't have this work on windows (no problem under
> linux) because of linking problems, I reproduced it there.
> [...]
> 5/  Here is the step I cannot pass, because there are always
> unresolved external symbols. I cannot guess which library I
> should link? Is it possible that I made something wrong when
> installing camlidl?

You can go one step further this way:

link /dll /out:somme_stubs.dll /def:somme_stubs.def \
   somme_stubs.obj somme.lib \
   /libpath:"c:/ocaml/lib" libcamlidl.lib ocamlrun.lib ole32.lib

somme_stubs.obj references symbols from libcamlidl.lib, 
and libcamlidl.lib references symbols from the OCaml runtime system,
hence the need to link the import library for the latter, ocamlrun.lib.

However, you run into the problem with Windows DLLs that I described
in my message of yesterday:

libcamlidl.lib(idlalloc.obj) : error LNK2001: unresolved external 
symbol _local_roots

That is, libcamlidl.lib was compiled for static linking with the OCaml
runtime system, not for dynamic linking.  Import libraries bridge the
differences between static and dynamic linking in the case of
references to functions, but not in the case of references to global
variables such as "local_roots".

So, basically, you can't do what you want to do with the current
version of CamlIDL.  The CamlIDL library would need to be compiled as
a DLL itself for this to work.

> I did the same thing on linux and it worked fine.

Welcome to the wonderful world of Windows DLL :-)

- Xavier Leroy

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