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] DLL_(windows)_creation_problem
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: <matthieu.dubuget@l...>
Subject: [Caml-list] DLL_(windows)_creation_problem
Hello camlers!

I experience a strange problem with the following on windows 98.

I have the following files:

=============== ===========================
let affiche dac =
  Printf.printf "%d\n" dac

=========== ms_dac.h =============================
void ms_dac_init ();
int ms_dac_init_ok (void);

=========== ms_dac.c =============================
#include "ms_dac.h"
#include <caml/callback.h>

static int ms_dac_init_done = 0;

void ms_dac_init (){
  char *vide = 0l;
  if (!ms_dac_init_done){
    caml_startup (&vide);
    ms_dac_init_done = 1;
int ms_dac_init_ok (void){
  return ms_dac_init_done;

=========== ms_dac.def ===========================

========== t.c ===================================
#include <stdio.h>
#include "ms_dac.h"

int main (){
  int ok;
  ok = ms_dac_init_ok();
  printf ("%d\n",ok);
  ok = ms_dac_init_ok();
  printf ("%d\n",ok);
  return 0;

C:\test>ocamlc -v
ocamlc -v
The Objective Caml compiler, version 3.08.0
Standard library directory: c:\ocaml\lib

C:\test>ocamlopt -output-obj -o dacl.obj

ocamlopt -output-obj -o dacl.obj

C:\test>ocamlopt -c ms_dac.c

ocamlopt -c ms_dac.c

C:\test>link -nologo -dll -out:ms_dac.dll -def:ms_dac.def
dacl.obj ms_dac.obj -libpath:c:\ocaml\lib libasmrun.lib
link -nologo -dll -out:ms_dac.dll -def:ms_dac.def dacl.obj
ms_dac.obj -libpath:c:\ocaml\lib libasmrun.lib
   Creating library ms_dac.lib and object ms_dac.exp

C:\test>cl -o t.exe -nologo -Ox -MT ms_dac.lib t.c
cl -o t.exe -nologo -Ox -MT ms_dac.lib t.c

<-------------------   At this step I get an error from Windows

If I modify the function definition (that uses Printf.printf) in
the ml file, their is no more error.

let affiche dac =
print_int dac

I suspect a conflict, or a missing library, but I can't find
what is going on exactly.

On linux, this gives the following with the original files:

$ ocamlc -v
The Objective Caml compiler, version 3.08.1
Standard library directory: /usr/lib/ocaml/3.08
$ ocamlopt -output-obj -o dac1.o
$ ocamlopt -c ms_dac.c
$ gcc -shared -o dac1.o ms_dac.o
-L/usr/lib/ocaml/3.08 -lasmrun
$ gcc -o t t.c -lm -ldl

Thanks in advance

Matthieu Dubuget

************************ ADSL ILLIMITE TISCALI + TELEPHONE GRATUIT ************************ 
Surfez 40 fois plus vite pour 30EUR/mois seulement !  Et téléphonez partout en France gratuitement,  
vers les postes fixes (hors numéros spéciaux). Tarifs très avantageux vers les mobiles et l'international !
Pour profiter de cette offre exceptionnelle, cliquez ici :  (voir conditions sur le site)

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