This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GCJ with native structs


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]