Segfault with trivial SWT snippet

Carl Worth cworth@cworth.org
Wed Nov 14 16:46:00 GMT 2007


On Wed, 14 Nov 2007 14:50:40 +0000, Andrew Haley wrote:
> Carl Worth writes:
>  > Oh, but by the way, I couldn't get things to link when passing the
>  > -findirect-dispatch flag. I always got errors like:
>  >
>  > 	gcj -I `pkg-config --variable=CLASSPATH swt-gtk`
>  > 	-findirect-dispatch -fpic -fjni -c -o Snippet1.o Snippet1.java
>  > 	gcj -lswt --main=Snippet1 -o Snippet1 Snippet1.o
>  > 	/tmp/cceivJSw.o: In function `main':
>  > 	ccUlWBRV.i:(.text+0x2b): undefined reference to `Snippet1::class$'
>
> You seem to have forgotten about -findirect-dispatch -fpic !

OK. That's fairly embarrassing.

I had really meant to stick to compile-and-link with one command to
avoid issues like this. Anyway, it does work if I do it correctly. For
example:

	gcj -I `pkg-config --variable=CLASSPATH swt-gtk` \
	-findirect-dispatch -fpic -fjni \
	-lswt --main=Snippet1 -o Snippet1 Snippet1.java

And it also works without those flags:

	gcj -I `pkg-config --variable=CLASSPATH swt-gtk` -lswt \
	--main=Snippet1 -o Snippet1 Snippet1.java

I'm curious now if there's a significant difference one way or the
other? Is something different happening or is the compiler figuring
things out and acting the same in both cases?

Thanks again for the help,

-Carl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/java/attachments/20071114/bf3ed089/attachment.sig>


More information about the Java mailing list