undefined reference to vtable
Bryce McKinlay
mckinlay@redhat.com
Tue Aug 10 20:56:00 GMT 2004
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
More information about the Java
mailing list