Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] camljava inside a toplvel ?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2003-07-23 (13:09)
Subject: [Caml-list] camljava inside a toplvel ?
i'm working with camljava (Xavier Leroy) to call java classes via caml.

It uses jni and c-caml callbacks to achieve this.

A library jni.cma, which permits caml to  achieve this.
In the test package, we have a, and 2 java classes.

The creation of an executable via ocamlc works fine

ocamlc -I +camljava jni.cma

launching the executable

CLASSPATH="." ./camlprog works fine.

I'm trying to execute directly the via the ocaml toplevel.

I've tried doing the following
ocaml -I +camljava jni.cma but it doesn't work, and i have an
error message that some external functions are not here
The external function `camljava_AllocObject' is not available

If i understand the problem, since these functions are declared as external,
i've tried to build a new toplevel, ocamljni which supports them.
Unfortunately, things don't seem to be that easy.

To achieve jni.cma, we have, jni.mli and jnistubs.c is compiled into a jni.cmo
jnistubs.c is compiled into jnistubs.obj

jnistubs.obj is put into library libcamljni.lib

jni.cmo and libcamljni.lib enter in the creation of jni.cma.

I've tried following the same approach, using libcamljni.lib and jni.cmo for
creating the ocamljni toplevel.
when i'm trying to do this
ocamlmktop -verbose -o ocamljni -linkall -custom jni.cmo -cclib -lcamljni
-cclib D:/APPLI/j2sdk1.4.1_01/lib/jvm.lib i'm having the following exception
in the linking process (CL)

+ cl /nologo /MT /Fe"mlfijni.exe" -I"D:\APPLI\MLFi\lib"
c:\TEMP\camlprimcd1cd1.c "libcamljni.lib" "D:/APPLI/j2sdk1.4.1_0
1/lib/jvm.lib" "D:\APPLI\MLFi\lib\libcamlrun.lib" advapi32.lib
camlprimcd1cd1.obj : error LNK2001: unresolved external symbol
mlfijni.exe : fatal error LNK1120: 1 unresolved externals
Error while building custom runtime system

The function camljava_CallStaticCamlintMethod is defined inside jnistubs.c,
and should be therefore present inside libcamljni.lib.

Am i missing something ??

Thanks in advance for your help.

Ce message et toutes les pieces jointes (ci-apres le "message") sont
confidentiels et etablis a l'intention exclusive de ses destinataires.
Toute utilisation ou diffusion non autorisee est interdite. 
Tout message electronique est susceptible d'alteration. 
SG Asset Management et ses filiales declinent toute responsabilite au titre
de ce message s'il a ete altere, deforme ou falsifie.

Découvrez l'offre et les services de SG Asset Management sur le site 


This message and any attachments (the "message") are confidential and
intended solely for the addressees.
Any unauthorised use or dissemination is prohibited. 
E-mails are susceptible to alteration.   
Neither SG Asset Management nor any of its subsidiaries or affiliates shall
be liable for the message if altered, changed or falsified. 


To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: