Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] ocamlopt and Windows DLL
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Dmitry Bely <dbely@m...>
Subject: [Caml-list] ocamlopt and Windows DLL
I am trying to build COM component written in ocaml using ocamlopt
compiler. To achive that I have slightly modified camlidldll script from
camlidl distribution. Now it builds DLL without a problem, but resulting
DLL never executes "let _ = ..." (_*_entry) constructs! After a short
investigation I have found the following code that seems to be causing the
problem:

[--- cfactory.cpp ---]
/* DLL entry point */

BOOL APIENTRY DllMain(HANDLE module, DWORD reason, void *reserved)
{
  char * argv[1];

  switch(reason) {
  case DLL_PROCESS_ATTACH:
    argv[0] = NULL;
    camlidl_module_handle = (HMODULE) module;
#if 0
    int fd = open("d:\\work\\camllog", O_RDWR|O_TRUNC|O_CREAT, _S_IWRITE|_S_IREAD);
    dup2(fd, 1);
    dup2(fd, 2);
    close(fd);
#endif
    caml_startup(argv);
    break;
  /* TODO: free all memory when DLL detached */
  }
  return TRUE;
}
[--- cfactory.cpp ---]

caml_startup() is called here with the empty argv list (no surprise, that's
DLL). Manual says that this is not acceptable for proper initialization of
the caml runtime library.

Does this mean that it's absolutely impossible to build DLL using ocamlopt?
Maybe there is a workaround?

Hope to hear from you soon,
Dmitry


-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr