<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2003/07/342f857b4e404c7db28559ad8cefffb0"
  from="matthieu.dubuget@libertysurf.fr &lt;matthieu.dubuget@l...&gt;"
  author="matthieu.dubuget@libertysurf.fr"
  date="2003-07-18T06:43:47"
  subject="[Caml-list] linking_problem_with_camlidl_on_windows"
  prev="2003/07/e9c6124bdfecdfc3581bcce8c957f2ca"
  next="2003/07/ea9fff535ebbc6622e8c36351b18a54d"
  next-in-thread="2003/07/6d3537c57139b19f19c21e09af95b09b"
  prev-thread="2003/07/348514c77483a81afd734d23858d5f77"
  next-thread="2003/07/5d2fdf4a723ea61c443961a0ab49053d"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] linking_problem_with_camlidl_on_windows">
<msg 
  url="2003/07/342f857b4e404c7db28559ad8cefffb0"
  from="matthieu.dubuget@libertysurf.fr &lt;matthieu.dubuget@l...&gt;"
  author="matthieu.dubuget@libertysurf.fr"
  date="2003-07-18T06:43:47"
  subject="[Caml-list] linking_problem_with_camlidl_on_windows">
<msg 
  url="2003/07/6d3537c57139b19f19c21e09af95b09b"
  from="Xavier Leroy &lt;xavier.leroy@i...&gt;"
  author="Xavier Leroy"
  date="2003-07-18T13:16:18"
  subject="Re: [Caml-list] linking problem with camlidl on windows">
</msg>
</msg>
</thread>

<contents>
Hello!

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.

There are 4 files :
somme.c, somme.def, somme.idl, somme_stubs.def

**** somme.c ****
#include "somme.h"

char * toto[3] = { "un", "deux", "trois" };

handle get(int indice){
  return toto[indice];
}

char * string_of_handle(handle h){
  return (char *) h;
}
**** somme.c ****
**** somme.def *****
EXPORTS
    get
    string_of_handle
**** somme.def *****

Here is the somme.idl file :

**** somme.idl ****
typedef [abstract] char *  handle;

handle get([in] int indice);

[string] char * string_of_handle([in] handle h);
**** somme.idl ****
**** somme_stubs.def ****
EXPORTS
    camlidl_somme_get
    camlidl_somme_string_of_handle
**** somme_stubs.def ****

Here are the steps (*files are the 4 hand-written files):

                           
*somme.def|-3-&gt;somme.dll|-5-&gt;somme_stubs.dll
               *somme.c|-2-&gt; somme.obj|             |
*somme.idl-1-&gt;|somme.h                              |
              |somme_stubs.c-4-&gt;    somme_stubs.obj |
              |                    *somme_stubs.def |
              |somme.ml
              |somme.mli

1/ ocamlidl -header somme.idl
2/ cl /c somme.c
3/ link /dll /out:somme.dll /def:somme.def somme.obj
4/ ocamlc -c somme_stubs.c

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?

FIRST TRY:
link /dll /out:somme_stubs.dll /def:somme_stubs.def
somme_stubs.obj somme.lib
Microsoft (R) Incremental Linker Version 6.00.8168
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

   Creating library somme_stubs.lib and object somme_stubs.exp
somme_stubs.obj : error LNK2001: unresolved external symbol
_alloc
somme_stubs.obj : error LNK2001: unresolved external symbol
_camlidl_free
somme_stubs.obj : error LNK2001: unresolved external symbol
_copy_string
somme_stubs.dll : fatal error LNK1120: 3 unresolved externals

SECOND TRY (worse):
link /dll /out:somme_stubs.dll /def:somme_stubs.def
somme_stubs.obj somme.lib /libpath:"c:/ocaml/lib" libcamlidl.lib
Microsoft (R) Incremental Linker Version 6.00.8168
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

   Creating library somme_stubs.lib and object somme_stubs.exp
somme_stubs.obj : error LNK2001: unresolved external symbol
_alloc
somme_stubs.obj : error LNK2001: unresolved external symbol
_copy_string
libcamlidl.lib(idlalloc.obj) : error LNK2001: unresolved
external symbol _invalid_argument
libcamlidl.lib(idlalloc.obj) : error LNK2001: unresolved
external symbol _alloc_small
libcamlidl.lib(idlalloc.obj) : error LNK2001: unresolved
external symbol _local_roots
libcamlidl.lib(idlalloc.obj) : error LNK2001: unresolved
external symbol _stat_alloc
libcamlidl.lib(idlalloc.obj) : error LNK2001: unresolved
external symbol _raise_out_of_memory
libcamlidl.lib(idlalloc.obj) : error LNK2001: unresolved
external symbol __imp__CoTaskMemAlloc@4
libcamlidl.lib(idlalloc.obj) : error LNK2001: unresolved
external symbol __imp__CoTaskMemFree@4
libcamlidl.lib(idlalloc.obj) : error LNK2001: unresolved
external symbol _stat_free
libcamlidl.lib(idlalloc.obj) : error LNK2001: unresolved
external symbol _string_length
somme_stubs.dll : fatal error LNK1120: 11 unresolved externals
NMAKE : fatal error U1077: 'link' : return code '0x460'
Stop.

COMMENTS:
I did the same thing on linux and it worked fine.
I did it with a simpler idl file on windows (without
abstract type definition) and it worked too.

Where am I wrong ?

Thanks in advance

Matthieu Dubuget


********** L'ADSL A 20 EUR/MOIS**********
Tiscali propose l'ADSL le moins cher du marché : 20 EUR/mois et le modem ADSL offert ! 
Pour profiter de cette offre exceptionnelle, cliquez ici : http://register.tiscali.fr/adsl/
Offre soumise à conditions.


-------------------
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

</contents>

</message>

