This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: Segfault with trivial SWT snippet
Carl Worth writes:
> On Tue, 13 Nov 2007 13:26:10 +0100, Mark Wielaard wrote:
> > On Tue, 2007-11-13 at 11:33 +0000, Andrew Haley wrote:
> > > Try compiling with -findirect-dispatch -fpic.
> >
> > And since swt uses JNI for its native bindings, you might also need to
> > add -fjni.
>
> Andre and Mark,
>
> Thanks for the help. The extra flags didn't solve the problem. But it
> did encourage me to try another experiment. I found that even if I
> used my System.out.println example with the compilation flags I was
> using that I got the segfault.
>
> So that made it simple to track down the problem to the following
> linker flags:
>
> -lswt -lswt-pi
>
> I found that if I just remove -lswt-pi then everything works great. (I
> have no idea what the intent of swt-pi might be---I had picked this up
> from the output of "pkg-config --libs swt-gtk"). So I'll pass that bug
> report on to the swt/Debian folks.
>
> Anyway, I think I'm on my way now.
OK.
> 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 !
Andrew.