* [Caml-list] embedding OCaml into C on win32
@ 2002-07-02 18:56 Alexander V.Voinov
2002-07-02 20:48 ` [Caml-list] camlp4 and anonymous function naming Julie Farago
2002-07-02 21:30 ` [Caml-list] embedding OCaml into C on win32 Alexander V.Voinov
0 siblings, 2 replies; 5+ messages in thread
From: Alexander V.Voinov @ 2002-07-02 18:56 UTC (permalink / raw)
To: caml-list
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Caml-list] camlp4 and anonymous function naming
2002-07-02 18:56 [Caml-list] embedding OCaml into C on win32 Alexander V.Voinov
@ 2002-07-02 20:48 ` Julie Farago
2002-07-03 8:08 ` Daniel de Rauglaudre
2002-07-02 21:30 ` [Caml-list] embedding OCaml into C on win32 Alexander V.Voinov
1 sibling, 1 reply; 5+ messages in thread
From: Julie Farago @ 2002-07-02 20:48 UTC (permalink / raw)
To: caml-list
camlp4 hackers,
I am trying to use camlp4 to name anonymous functions. I want to take code
that in the form:
fun <args> -> <body>
and convert it to:
let anonfunc<number> <args> = <body> in anonfunc<number>
I've read over the camlp4 tutorial and have some sense of how to do this,
but am getting stuck because I do not know the correct syntax to use. I
currently am extending the grammar with:
EXTEND
expr:
[[ "fun" ; vars = LIST1 LIDENT ; "->" ; e = expr ->
givenames loc vars e ]]
;
END;;
and then I try and re-write the anonymous function with:
let namefun =
let cnt = ref 0 in
fun var -> let x = incr cnt ; !cnt in
var ^ "_genfun" ^ string_of_int x
let givenames loc vars e =
let name = namefun "my" in
<:expr<
let $lid:name$ $vars$ = $e$
in $lid:name$ >>
This code is, of course, wrong. The problem is that I cannot figure out
how to simply capture the args from the fun and place them back into the
let.
Any direction you could provide on this would be great!
-Julie
-------------------
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] 5+ messages in thread
* Re: [Caml-list] embedding OCaml into C on win32
2002-07-02 18:56 [Caml-list] embedding OCaml into C on win32 Alexander V.Voinov
2002-07-02 20:48 ` [Caml-list] camlp4 and anonymous function naming Julie Farago
@ 2002-07-02 21:30 ` Alexander V.Voinov
2002-07-02 22:32 ` Alexander V.Voinov
1 sibling, 1 reply; 5+ messages in thread
From: Alexander V.Voinov @ 2002-07-02 21:30 UTC (permalink / raw)
To: caml-list
From: "Alexander V.Voinov" <avv@quasar.ipa.nw.ru>
Subject: [Caml-list] embedding OCaml into C on win32
Date: Tue, 02 Jul 2002 11:56:19 -0700 (PDT)
> 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.
Same on Solaris. Please help! I don't know any other source
of information except the manual 'Chapter 17 Interfacing C with Objective Caml'
and it seems that I follow it.
Thank you
Alexander
-------------------
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] 5+ messages in thread
* Re: [Caml-list] embedding OCaml into C on win32
2002-07-02 21:30 ` [Caml-list] embedding OCaml into C on win32 Alexander V.Voinov
@ 2002-07-02 22:32 ` Alexander V.Voinov
0 siblings, 0 replies; 5+ messages in thread
From: Alexander V.Voinov @ 2002-07-02 22:32 UTC (permalink / raw)
To: caml-list
Hi
I denounce this question, sorry.
Alexander
From: "Alexander V.Voinov" <avv@quasar.ipa.nw.ru>
Subject: Re: [Caml-list] embedding OCaml into C on win32
Date: Tue, 02 Jul 2002 14:30:37 -0700 (PDT)
> From: "Alexander V.Voinov" <avv@quasar.ipa.nw.ru>
> Subject: [Caml-list] embedding OCaml into C on win32
> Date: Tue, 02 Jul 2002 11:56:19 -0700 (PDT)
>
> > 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.
>
> Same on Solaris. Please help! I don't know any other source
> of information except the manual 'Chapter 17 Interfacing C with Objective Caml'
> and it seems that I follow it.
-------------------
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] 5+ messages in thread
* Re: [Caml-list] camlp4 and anonymous function naming
2002-07-02 20:48 ` [Caml-list] camlp4 and anonymous function naming Julie Farago
@ 2002-07-03 8:08 ` Daniel de Rauglaudre
0 siblings, 0 replies; 5+ messages in thread
From: Daniel de Rauglaudre @ 2002-07-03 8:08 UTC (permalink / raw)
To: caml-list
Hi,
On Tue, Jul 02, 2002 at 04:48:22PM -0400, Julie Farago wrote:
> let givenames loc vars e =
> let name = namefun "my" in
> <:expr<
> let $lid:name$ $vars$ = $e$
> in $lid:name$ >>
>
> This code is, of course, wrong. The problem is that I cannot figure out
> how to simply capture the args from the fun and place them back into the
> let.
Write this function like this:
let givenames loc vars e =
let name = namefun "my" in
let e =
List.fold_right (fun p e -> <:expr< fun $lid:p$ -> $e$ >>) vars e
in
<:expr<
let $lid:name$ = $e$
in $lid:name$ >>
--
Daniel de RAUGLAUDRE
daniel.de_rauglaudre@inria.fr
http://cristal.inria.fr/~ddr/
-------------------
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] 5+ messages in thread
end of thread, other threads:[~2002-07-03 8:08 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-02 18:56 [Caml-list] embedding OCaml into C on win32 Alexander V.Voinov
2002-07-02 20:48 ` [Caml-list] camlp4 and anonymous function naming Julie Farago
2002-07-03 8:08 ` Daniel de Rauglaudre
2002-07-02 21:30 ` [Caml-list] embedding OCaml into C on win32 Alexander V.Voinov
2002-07-02 22:32 ` Alexander V.Voinov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox