<?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="2002/07/562bfd7c9196fc3abcb454d8d4965868"
  from="Alexander V.Voinov &lt;avv@q...&gt;"
  author="Alexander V.Voinov"
  date="2002-07-02T18:59:08"
  subject="[Caml-list] embedding OCaml into C on win32"
  prev="2002/07/1d39e152576c2aabdc0ee99c33754e7a"
  next="2002/07/69515a2d7d7e36df2caff6fbd0eddfa3"
  next-in-thread="2002/07/69515a2d7d7e36df2caff6fbd0eddfa3"
  prev-thread="2002/07/1c3e421998b8c597856d6c991ff07910"
  next-thread="2002/07/729263137a5c609a8795ff7b62ccf4d0"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] embedding OCaml into C on win32">
<msg 
  url="2002/07/562bfd7c9196fc3abcb454d8d4965868"
  from="Alexander V.Voinov &lt;avv@q...&gt;"
  author="Alexander V.Voinov"
  date="2002-07-02T18:59:08"
  subject="[Caml-list] embedding OCaml into C on win32">
<msg 
  url="2002/07/69515a2d7d7e36df2caff6fbd0eddfa3"
  from="Julie Farago &lt;farago@e...&gt;"
  author="Julie Farago"
  date="2002-07-02T20:48:24"
  subject="[Caml-list] camlp4 and anonymous function naming">
<msg 
  url="2002/07/8aaf29027d45ab74beaf633b7b6c51b7"
  from="Daniel de Rauglaudre &lt;daniel.de_rauglaudre@i...&gt;"
  author="Daniel de Rauglaudre"
  date="2002-07-03T08:08:10"
  subject="Re: [Caml-list] camlp4 and anonymous function naming">
</msg>
</msg>
<msg 
  url="2002/07/380f1d9276b23b4d004f27ca65e5bb07"
  from="Alexander V.Voinov &lt;avv@q...&gt;"
  author="Alexander V.Voinov"
  date="2002-07-02T21:33:28"
  subject="Re: [Caml-list] embedding OCaml into C on win32">
<msg 
  url="2002/07/1938bd06a7295f31e5fee044ccfdda3a"
  from="Alexander V.Voinov &lt;avv@q...&gt;"
  author="Alexander V.Voinov"
  date="2002-07-02T22:35:38"
  subject="Re: [Caml-list] embedding OCaml into C on win32">
</msg>
</msg>
</msg>
</thread>

<contents>
Hi 

I have a small program, similar to one in the manual (where
fib_closure is defined). I try it on win32, with VC 6 and
ocaml-3.04.

The Makefile and the source texts are as follows. What else should I
add to the link command to resolve these externals?

Thank you

Alexander
=======Makefile:========================================================
PROG=test2

%.obj: %.ml
	ocamlopt -output-obj -c -o $@ $&lt;  

%.obj: %.cpp
	cl /c /nologo /MT /Ic:/ocaml/lib $&lt;

%.obj: %.c
	cl /c /nologo /MT /Ic:/ocaml/lib $&lt;

run: $(PROG).exe
	./$(PROG).exe

$(PROG).exe: $(PROG).obj mltest.obj
	link /nologo $^ /OUT:$@ /libpath:"c:/ocaml/lib" libasmrun.lib
=======test2.c:=========================================================
#include &lt;stdio.h&gt;
#include &lt;caml/mlvalues.h&gt;
#include &lt;caml/alloc.h&gt;
#include &lt;caml/memory.h&gt;
#include &lt;caml/callback.h&gt;
#include &lt;caml/custom.h&gt;

int ml_inc(int n)
{
    static value * ml_inc_closure = NULL;
    if (ml_inc_closure == NULL)
	ml_inc_closure = caml_named_value("ml_inc");
    return Int_val(callback(*ml_inc_closure, Val_int(n)));
}

int main()
{
    char *argv[] = { NULL };
    int n;
    
    printf("In main\n"); fflush(stdout);

    caml_startup(argv);

    n = ml_inc(10);
    
    printf("n = %d\n", n); fflush(stdout);
    return 0;
}
======mltest.ml=========================================================
let ml_inc i = i + 1

let _ = Callback.register "ml_inc" ml_inc
======output:===========================================================
gmake -k 
cl /c /nologo /MT /Ic:/ocaml/lib test2.c
test2.c
ocamlopt -output-obj -c -o mltest.obj mltest.ml  
link /nologo test2.obj mltest.obj /OUT:test2.exe /libpath:"c:/ocaml/lib" libasmrun.lib
libasmrun.lib(startup.obj) : error LNK2001: unresolved external symbol _caml_code_segments
libasmrun.lib(startup.obj) : error LNK2001: unresolved external symbol _caml_data_segments
libasmrun.lib(fail.obj) : error LNK2001: unresolved external symbol _Failure
libasmrun.lib(fail.obj) : error LNK2001: unresolved external symbol _Invalid_argument
libasmrun.lib(fail.obj) : error LNK2001: unresolved external symbol _Out_of_memory
libasmrun.lib(fail.obj) : error LNK2001: unresolved external symbol _Stack_overflow
libasmrun.lib(fail.obj) : error LNK2001: unresolved external symbol _Sys_error
libasmrun.lib(fail.obj) : error LNK2001: unresolved external symbol _End_of_file
libasmrun.lib(fail.obj) : error LNK2001: unresolved external symbol _Division_by_zero
libasmrun.lib(fail.obj) : error LNK2001: unresolved external symbol _Not_found
libasmrun.lib(fail.obj) : error LNK2001: unresolved external symbol _Sys_blocked_io
libasmrun.lib(i386nt.obj) : error LNK2001: unresolved external symbol _caml_apply2
libasmrun.lib(i386nt.obj) : error LNK2001: unresolved external symbol _caml_apply3
libasmrun.lib(i386nt.obj) : error LNK2001: unresolved external symbol _caml_program
libasmrun.lib(roots.obj) : error LNK2001: unresolved external symbol _caml_frametable
libasmrun.lib(roots.obj) : error LNK2001: unresolved external symbol _caml_globals
test2.exe : fatal error LNK1120: 16 unresolved externals
-------------------
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>

