Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] embedding OCaml into C on win32
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Alexander V.Voinov <avv@q...>
Subject: [Caml-list] embedding OCaml into C on win32
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 $@ $<  

%.obj: %.cpp
	cl /c /nologo /MT /Ic:/ocaml/lib $<

%.obj: %.c
	cl /c /nologo /MT /Ic:/ocaml/lib $<

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

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

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