[2883] in java-interest
C++ native modules!!
daemon@ATHENA.MIT.EDU (P Senthilkumar - RS)
Thu Oct 19 06:02:48 1995
From: psenthil@iss.nus.sg (P Senthilkumar - RS)
To: java-interest@java.sun.com, Arthur.Vanhoff@Eng.Sun.COM
Date: Thu, 19 Oct 1995 16:20:15 +0800 (SST)
Cc: psenthil@iss.nus.sg (P Senthilkumar - RS)
hi,
I dont know whether this is possible or not.
Is it possible to load a dll created from a c++ code.
I guess this is not possible. Becoz no where in the documents I find
this is mentioned. Also it was only illustrated for C code.
(I knew that the StepbyStep docs doesnt mention c++ anywhere, but I
just wanted to test it out. becoz iam desperately in need of this)
I got curious and tried playing with the Helloworld.c and tried
to link with the dll created using g++.
Please dont flame me for this. Because, Iam trying to use native c++
routines to create peristent object repository. Iam using Shore as
my Storage Manager.
Currently, my idea is this: If loading a dll (created out of c++) is
possible, then i thought System.loadLibrary() will be helpful for me
create object-types dynamically and there by make my system
extensible.
Please correct me if iam wrong, or if iam making some blind assumptions.
But it failed during linking.
To give a clear picture :
This is my modified hello.c
#include <StubPreamble.h>
#include "Helloworld.h"
#include <iostream.h>
void Helloworld_displayHelloworld(struct HHelloworld *t)
{
cout <<"adfsg"<<endl;
return;
}
I created libHelloworld.so by
g++ -G -I$JAVAHOME/include -I$JAVAHOME/include/solaris HelloWorld.c hello.C -o
libHelloworld.so
On running this I get
ld.so.1: /usr2/psenthil/java/bin/../bin/sun4/java: fatal: relocation
error: symbol not found: Helloworld_displayHelloworld__FPv: referenced
in /usr2/psenthil/hotjava-psk/native/cpp/libHelloworld.so
(/usr2/psenthil/hotjava-psk/native/cpp/libHelloworld.so)
java.lang.UnsatisfiedLinkError no Helloworld in LD_LIBRARY_PATH
at java.lang.Throwable.<init>(Throwable.java)
at java.lang.Error.<init>(Error.java)
at java.lang.LinkageError.<init>(LinkageError.java)
at java.lang.UnsatisfiedLinkError.<init>(UnsatisfiedLinkError.java)
at java.lang.Runtime.loadLibrary(Runtime.java)
at java.lang.System.loadLibrary(System.java)
at Helloworld.<clinit>(Helloworld.java:6)
at java.lang.UnsatisfiedLinkError displayHelloworld
at pgm.main(Helloworld.java:13)
LD_LIBRARY_PATH= <is properly set>
When i changed the cout and iostream to printf and compiled with g++ I
get the same error.
Any help and solutions are welcome.
Thanks in advance.
Senthil
-----------------------**************-------------------
"Good judgement comes from experience. Experience comes
from bad judgement."
-- Jim Horning
-----------------------**************-------------------
P. Senthil kumar Internet : psenthil@iss.nus.sg
Institute of System Sciences, Talk : psenthil@melon.iss.nus.sg
National University of Singapore, Tel : 7722583 (O)
Singapore -0511 : 4720790 (R)
------------------------------------------------------------------------
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com