GCJ with native structs

Stanley Brown stanley.brown@zimmer.com
Mon Dec 8 20:11:00 GMT 2003


I am having a problem where gcj is unable to handle my CNI code creating 
an instance of a structure. I created a simple example to illustrate:
public class Test
{
 public Test()
 {
 nativeTest();
 }
 public native void nativeTest();
 public static void main(String args[])
 {
 new Test();
 }
}
Okay, now I used gcjh to create a stub and header. Heres the Test.cc code:
#include <gcj/cni.h>
#include "Test.h"
typedef struct
{
 int a;
} TestStruct;
void
Test::nativeTest ()
{
 new TestStruct;
}
I compile the C++ code:
g++ -c Test.cc -o natTest.cc
Now build:
gcj --main=Test Test.java natTest.o
Heres the error I get:
natTest.o(.text+0xe):Test.cc: undefined reference to `operator 
new(unsigned)'
natTest.o(.rdata$_ZTI4Test+0x0):Test.cc: undefined reference to `vtable 
for __cx
xabiv1::__class_type_info'
Do I need to add something for linking? I tested the following using 
just C++ and it worked fine:
class Test
{
public:
 Test ();
 virtual void nativeTest ();
};
typedef struct
{
 int a;
} TestStruct;
Test::Test () {}
void
Test::nativeTest ()
{
 new TestStruct;
}
main()
{
 Test *test = new Test();
 test->nativeTest();
}
gcc (GCC) 3.4 20031123 (experimental) on Windows XP


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /