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]

Re: undefined reference to vtable


Shaun Jackman wrote:

I'm writing a C++ program that calls a Java shared library. I'm seeing
undefined references to the vtable for a class defined using C++.

$ make
g++-3.4 -g -O2 -o HelloWorld HelloWorld.o -lswt -lswt-pi
HelloWorld.o(.text+0x136): In function `main':
/home/sjackman/work/hello/swt-cni/HelloWorld.cc:62: undefined reference to `java::lang::Object::Object()'
HelloWorld.o(.text+0x13e):/home/sjackman/work/hello/swt-cni/HelloWorld.cc:62: undefined reference to `vtable for ShellSelectionListener'
collect2: ld returned 1 exit status
make: *** [HelloWorld] Error 1



Shaun,


You need to either:

- add "-lgcj" to your link command, or
- Use "gcj" to link, not "g++"

Regards

Bryce


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