caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Re: [Caml-list] DLL (windows) creation problem
@ 2004-09-24  7:27 matthieu.dubuget
  2004-09-24 15:21 ` Igor Pechtchanski
  0 siblings, 1 reply; 6+ messages in thread
From: matthieu.dubuget @ 2004-09-24  7:27 UTC (permalink / raw)
  To: caml-list

The same thing with bytecode (replaced ocamlopt by ocamlc,
and libasmrun.lib by libcamlrun.lib) works. Why?

C:\test>ocamlc -output-obj -o dac1.obj dac.ml
C:\test>ocamlc -c ms_dac.c
C:\test>link -nologo -dll -out:ms_dac.dll -def:ms_dac.def
dac1.obj ms_dac.obj -libpath:c:\ocaml\lib libcamlrun.lib
C:\test>cl -o t.exe -nologo -Ox -MT ms_dac.lib t.c
C:\test>t.exe 
t.exe 
0
1


Salutations

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 : http://register.tiscali.fr/adsl  (voir conditions sur le site)


-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] DLL (windows) creation problem
  2004-09-24  7:27 [Caml-list] DLL (windows) creation problem matthieu.dubuget
@ 2004-09-24 15:21 ` Igor Pechtchanski
  0 siblings, 0 replies; 6+ messages in thread
From: Igor Pechtchanski @ 2004-09-24 15:21 UTC (permalink / raw)
  To: Matthieu Dubuget; +Cc: caml-list

On Fri, 24 Sep 2004, matthieu.dubuget wrote:

> The same thing with bytecode (replaced ocamlopt by ocamlc,
> and libasmrun.lib by libcamlrun.lib) works. Why?
>
> C:\test>ocamlc -output-obj -o dac1.obj dac.ml
> C:\test>ocamlc -c ms_dac.c
> C:\test>link -nologo -dll -out:ms_dac.dll -def:ms_dac.def
> dac1.obj ms_dac.obj -libpath:c:\ocaml\lib libcamlrun.lib
> C:\test>cl -o t.exe -nologo -Ox -MT ms_dac.lib t.c
> C:\test>t.exe
> t.exe
> 0
> 1
>
> Salutations
> Matthieu Dubuget

I suspect it's because the bytecode linking mechanism does different
things for dependencies (e.g., they aren't represented as unresolved
symbols).  Hopefully, someone will correct me if I'm wrong.

Igor Pechtchanski, volunteer O'Caml maintainer for Cygwin
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha@cs.nyu.edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor@watson.ibm.com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"Happiness lies in being privileged to work hard for long hours in doing
whatever you think is worth doing."  -- Dr. Jubal Harshaw

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] DLL (windows) creation problem
  2004-09-23 19:08   ` Matthieu Dubuget
@ 2004-09-23 20:25     ` Igor Pechtchanski
  0 siblings, 0 replies; 6+ messages in thread
From: Igor Pechtchanski @ 2004-09-23 20:25 UTC (permalink / raw)
  To: Matthieu Dubuget; +Cc: caml-list

On Thu, 23 Sep 2004, Matthieu Dubuget wrote:

> Igor Pechtchanski wrote:
>
> > The dependent DLL should be in the PATH (instead of LD_LIBRARY_PATH).
> > Windows should tell you which DLL is missing (I suspect it's the one that
> > contains the Printf module).
>
> That's part of what puzzle me: no indication. Just one runtime invalid
> operation.

I'm sorry, I was wrong.  The normal DLL loading mechanism will report the
name of the DLL that's missing, but LoadLibrary will simply set the error
and exit.  You could use a DLL dependency tool to find out which DLL yours
depends on (e.g., Cygwin's "cygcheck", which will also work on non-Cygwin
DLLs/programs).

> > FWIW, I've just posted a Cygwin ocaml package version that supports
> > dynamic linking and should let you use the above Linux transcript almost
> > verbatim (only tested on WinXP for now, see
> > <http://cygwin.com/ml/cygwin-apps/2004-09/msg00195.html>).  It's not on
> > the mirrors yet, but feel free to test it out, and, if you do, please
> > report the results to me or the Cygwin list (<cygwin at cygwin dot com>).
>
> I surely will try it!
>
> And will also try to have my little test compiled with:
>
> - a static lib instead of a DLL to see if i get more informations from MS
> toolchain
> - bytecode version

I'd be interested in the results (hopefully positive) of your tests.  Feel
free to e-mail me directly with this info.

Igor Pechtchanski, volunteer O'Caml maintainer for Cygwin
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha@cs.nyu.edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor@watson.ibm.com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"Happiness lies in being privileged to work hard for long hours in doing
whatever you think is worth doing."  -- Dr. Jubal Harshaw

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] DLL (windows) creation problem
  2004-09-23 16:57 ` Igor Pechtchanski
@ 2004-09-23 19:08   ` Matthieu Dubuget
  2004-09-23 20:25     ` Igor Pechtchanski
  0 siblings, 1 reply; 6+ messages in thread
From: Matthieu Dubuget @ 2004-09-23 19:08 UTC (permalink / raw)
  To: caml-list

Igor Pechtchanski wrote:

> 
> The dependent DLL should be in the PATH (instead of LD_LIBRARY_PATH).
> Windows should tell you which DLL is missing (I suspect it's the one that
> contains the Printf module).

That's part of what puzzle me: no indication. Just one runtime invalid 
operation.

> FWIW, I've just posted a Cygwin ocaml package version that supports
> dynamic linking and should let you use the above Linux transcript almost
> verbatim (only tested on WinXP for now, see
> <http://cygwin.com/ml/cygwin-apps/2004-09/msg00195.html>).  It's not on
> the mirrors yet, but feel free to test it out, and, if you do, please
> report the results to me or the Cygwin list (<cygwin at cygwin dot com>).

I surely will try it!

And will also try to have my little test compiled with:

- a static lib instead of a DLL to see if i get more informations from 
MS toolchain
- bytecode version

Thanks

Matthieu

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] DLL (windows) creation problem
  2004-09-23 16:44 matthieu.dubuget
@ 2004-09-23 16:57 ` Igor Pechtchanski
  2004-09-23 19:08   ` Matthieu Dubuget
  0 siblings, 1 reply; 6+ messages in thread
From: Igor Pechtchanski @ 2004-09-23 16:57 UTC (permalink / raw)
  To: matthieu.dubuget; +Cc: caml-list

On Thu, 23 Sep 2004, matthieu.dubuget wrote:

> Hello camlers!
>
> I experience a strange problem with the following on windows 98.
>
> I have the following files:
>
> =============== dac.ml ===========================
> 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 ===========================
> EXPORTS
> ms_dac_init
> ms_dac_init_ok
> ==================================================
>
> ========== t.c ===================================
> #include <stdio.h>
> #include "ms_dac.h"
>
> int main (){
>   int ok;
>   ok = ms_dac_init_ok();
>   printf ("%d\n",ok);
>   fflush(stdout);
>   ms_dac_init();
>   ok = ms_dac_init_ok();
>   printf ("%d\n",ok);
>   fflush(stdout);
>   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 dac.ml
>
> ocamlopt -output-obj -o dacl.obj dac.ml
>
> C:\test>ocamlopt -c ms_dac.c
>
> ocamlopt -c ms_dac.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
> t.c
>
> C:\test>t.exe
> t.exe
> 0
> <-------------------   At this step I get an error from Windows

The dependent DLL should be in the PATH (instead of LD_LIBRARY_PATH).
Windows should tell you which DLL is missing (I suspect it's the one that
contains the Printf module).

> 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

That's no surprise -- "print_int" is built into the ocaml binary, so your
DLL is not dependent on other DLLs anymore.

> I suspect a conflict, or a missing library, but I can't find out 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 dac.ml
> $ ocamlopt -c ms_dac.c
> $ gcc -shared -o libdac.so dac1.o ms_dac.o
> -L/usr/lib/ocaml/3.08 -lasmrun
> $ gcc -o t libdac.so t.c -lm -ldl
> $ LD_LIBRARY_PATH=. ./t
> 0
> 1
> $
>
> Thanks in advance
> Matthieu Dubuget

FWIW, I've just posted a Cygwin ocaml package version that supports
dynamic linking and should let you use the above Linux transcript almost
verbatim (only tested on WinXP for now, see
<http://cygwin.com/ml/cygwin-apps/2004-09/msg00195.html>).  It's not on
the mirrors yet, but feel free to test it out, and, if you do, please
report the results to me or the Cygwin list (<cygwin at cygwin dot com>).

Igor Pechtchanski
Volunteer O'Caml maintainer for Cygwin.
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha@cs.nyu.edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor@watson.ibm.com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"Happiness lies in being privileged to work hard for long hours in doing
whatever you think is worth doing."  -- Dr. Jubal Harshaw

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Caml-list] DLL (windows) creation problem
@ 2004-09-23 16:44 matthieu.dubuget
  2004-09-23 16:57 ` Igor Pechtchanski
  0 siblings, 1 reply; 6+ messages in thread
From: matthieu.dubuget @ 2004-09-23 16:44 UTC (permalink / raw)
  To: caml-list; +Cc: matthieu.dubuget

Hello camlers!

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

I have the following files:

=============== dac.ml ===========================
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 ===========================
EXPORTS
ms_dac_init
ms_dac_init_ok
==================================================

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

int main (){
  int ok;
  ok = ms_dac_init_ok();
  printf ("%d\n",ok);
  fflush(stdout);
  ms_dac_init();
  ok = ms_dac_init_ok();
  printf ("%d\n",ok);
  fflush(stdout);
  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 dac.ml

ocamlopt -output-obj -o dacl.obj dac.ml

C:\test>ocamlopt -c ms_dac.c

ocamlopt -c ms_dac.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
t.c

C:\test>t.exe 
t.exe 
0
<-------------------   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
out 
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 dac.ml
$ ocamlopt -c ms_dac.c
$ gcc -shared -o libdac.so dac1.o ms_dac.o
-L/usr/lib/ocaml/3.08 -lasmrun
$ gcc -o t libdac.so t.c -lm -ldl
$ LD_LIBRARY_PATH=. ./t
0
1
$ 

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 : http://register.tiscali.fr/adsl  (voir conditions sur le site)


-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2004-09-24 15:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-24  7:27 [Caml-list] DLL (windows) creation problem matthieu.dubuget
2004-09-24 15:21 ` Igor Pechtchanski
  -- strict thread matches above, loose matches on Subject: below --
2004-09-23 16:44 matthieu.dubuget
2004-09-23 16:57 ` Igor Pechtchanski
2004-09-23 19:08   ` Matthieu Dubuget
2004-09-23 20:25     ` Igor Pechtchanski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).