This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: undefined reference to vtable
- From: Bryce McKinlay <mckinlay at redhat dot com>
- To: Shaun Jackman <sjackman at telus dot net>
- Cc: java at gcc dot gnu dot org
- Date: Tue, 10 Aug 2004 16:35:50 -0400
- Subject: Re: undefined reference to vtable
- References: <200408101247.54741.sjackman@telus.net>
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