This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
RE: gcj swt (motif)
- From: "Erik Poupaert" <erik dot poupaert at chello dot be>
- To: "David Young" <dvd at OCF dot Berkeley dot EDU>
- Cc: <java at gcc dot gnu dot org>
- Date: Sat, 12 Apr 2003 14:07:16 +0200
- Subject: RE: gcj swt (motif)
Since you've added another variable to the mix -- swt based on motif,
instead of swt based on gtk -- there may be peculiarities related to it.
However, the error messages you've encountered look very familiar to me.
I've struggled with similar ones, until it finally worked out all right.
I've got it to work with two different strategies:
(1) libswt-gtk-XXXX.so and libswt-gtk-pi-YYYY.so compiled separately.
(2) libswt-gtk-XXXX.a and libswt-gtk-pi-YYYY.a statically integrated into
the executable.
There are other build strategies possible.
If you follow strategy (1), you need to leave the loadLibrary() calls
enabled. Otherwise, you have to disable them.
>>>> When I tried a HelloWorld program, however, I got an
>>>> "java.lang.UnsatisfiedLinkError":
This one is issued by libjava, because swt.internal.Library tries to load a
library that cannot be found. If you follow strategy (1), see to it that
libswt*.so are on your LD_LIBRARY_PATH one way or the other. Otherwise, (2)
disable the calls.
You may also not touch LD_LIBRARY_PATH but instruct gcj to search for
libraries with the "-L" option, while linking or while loading executables.
For example: -L/usr/lib -L/usr/X11R6/lib
>>>> I tried un-commenting the 2 "System.loadLibrary (newName);" calls in
>>>> "org/eclipse/swt/internal/Library.java", and instead I got the error:
>>>> Exception in thread "main" java.lang.UnsatisfiedLinkError:
>>>> swt-motif-2133: file not found
>>>> I cannot find "swt-motif-2133" anywhere on my system, but I do see
>>>> "libswt-motif-2133.so". Soft linking it to "swt-motif-2133" didn't do
>>>> the trick.
The gcj option "-l"mylib looks for libmylib. Rename swt-motif-2133.so to
libswt-motif-2133.so. That may very well do the trick.
>>>> When I tried to compile the loadLibrary-commented-out version
>>>> statically, I simply got the error:
>>>> build-hellogcjswt.sh: ./HelloGCJSWT: /usr/lib/libc.so.1: bad ELF
>>>> interpreter: No such file or directory
I got that one too. I don't remember why it happened, but I believe it's
related to improper static linking. Adding "-static" when linking with gtk
does not help (motif, I don't know). You must re-compile gtk (or motif)
with static support first. I haven't gone through on that, but you can be
sure that statically linking against gtk (or motif) cannot be effected by
just adding "-static".
When persuing strategy (2), make sure to include the swt-jni support library
with the whole archive library option:
-Wl,--whole-archive libswt-motif-pi-2133.a -Wl,--no-whole-archive
Otherwise you will invariably find that symbols are missing. The java-part
of swt does not need to be linked with the whole archive option, since no
reflection or other dynamic lookup tactic is in use. Everything is
referenced explicitly. Therefore, the linker will successfully include all
symbols referenced from your program.
Hope this helps.