GCJ Swing/AWT working on OS X -- article
John Gabriele
john3g@bestweb.net
Thu Jul 22 01:46:00 GMT 2004
On Jul 21, 2004, at 9:01 PM, Bryce McKinlay wrote:
> John Gabriele wrote:
>
>> Thanks Bryce.
>>
>> Should I be adding a '-l' arg to my build command line?
>> (note, my gnome-related libs are in ~/src/gnome/objdir/lib)
>> Hmm... here's what that gets me:
>>
>> ~/temp/gcj_stuff $ gcj -o baz --main=TestAWT -l
>> ~/src/gnome/objdir/lib TestAWT.java
>> /usr/bin/ld: can't locate file for: -l/Users/john/src/gnome/objdir/lib
>> collect2: ld returned 1 exit status
>
>
> Normally, libgcj will look for the toolkit classes in a file called
> lib-gnu-java-awt-peer-gtk.so (.dylib on OS X) in your LD_LIBRARY_PATH
> (DYLD_LIBRARY_PATH on OS X).
>
> So, try setting DYLD_LIBRARY_PATH to point to the directory containing
> lib-gnu-java-awt-peer-gtk.dylib. If that doesn't work, it is possible
> that the library loading mechanism that libgcj uses is not working
> correctly on OS X.
>
> Regards
>
> Bryce
>
Thanks for the reply Bryce.
Well, I've got gcc installed in /usr/local/gcc_cvs, and I had set
DYLD_LIBRARY_PATH to /usr/local/gcc_cvs/lib and had *not* set CLASSPATH,
so I think I was already doing what you suggest:
~/temp/gcj_stuff $ ls /usr/local/gcc_cvs/lib/lib*awt*
/usr/local/gcc_cvs/lib/lib-gnu-java-awt-peer-gtk.6.0.0.dylib*
/usr/local/gcc_cvs/lib/lib-gnu-java-awt-peer-gtk.dylib@
/usr/local/gcc_cvs/lib/lib-gnu-java-awt-peer-gtk.6.dylib@
/usr/local/gcc_cvs/lib/lib-gnu-java-awt-peer-gtk.la*
~/temp/gcj_stuff $ echo $CLASSPATH
~/temp/gcj_stuff $ echo $DYLD_LIBRARY_PATH
/usr/local/gcc_cvs/lib
~/temp/gcj_stuff $ ls
TestAWT.java
~/temp/gcj_stuff $ gcj -o baz --main=TestAWT TestAWT.java
/usr/bin/ld: warning multiple definitions of symbol _sqrt
/usr/local/gcc_cvs/lib/gcc/powerpc-apple-darwin7.4.0/3.5.0/../../../
libgcj.dylib(libgcj.6.0.0.dylib-master.o) definition of _sqrt
/usr/lib/libm.dylib(sqrt970.o) definition of _sqrt
~/temp/gcj_stuff $ ls -l
total 344
-rw-r--r-- 1 john john 14126 21 Jul 18:47 TestAWT.java
-rwxr-xr-x 1 john john 156620 21 Jul 21:17 baz*
~/temp/gcj_stuff $ ./baz
Exception in thread "main" java.awt.AWTError: Cannot load AWT toolkit:
gnu.java.awt.peer.gtk.GtkToolkit
<<No stacktrace available>>
Caused by: java.lang.ClassNotFoundException:
gnu.java.awt.peer.gtk.GtkToolkit not found in [file:./, core:/]
<<No stacktrace available>>
Does /usr/local/gcc_cvs/share/java/libgcj-3.5.0.jar internally make use
of /usr/local/gcc_cvs/lib/lib-gnu-java-awt-peer-gtk.6.0.0.dylib ?
Note: OS X comes with otool (rather than ldd), but unfortunately I
can't do this:
~/temp/gcj_stuff $ otool -L
/usr/local/gcc_cvs/share/java/libgcj-3.5.0.jar
/usr/local/gcc_cvs/share/java/libgcj-3.5.0.jar: is not an object file
You mentioned:
> Odd. For some reason the compiled versions of the Gtk AWT peer classes
> couldn't be found. By putting them on the classpath, you'll be running
> interpreted bytecode, not natively compiled code. This will reduce
> performance.
How can I tell when I'm running natively compiled code vs. when I'm
running interpreted bytecode?
~/temp/gcj_stuff $ export
CLASSPATH=/usr/local/gcc_cvs/share/java/libgcj-3.5.0.jar
~/temp/gcj_stuff $ gcj -o baz2 --main=TestAWT TestAWT.java
/usr/bin/ld: warning multiple definitions of symbol _sqrt
/usr/local/gcc_cvs/lib/gcc/powerpc-apple-darwin7.4.0/3.5.0/../../../
libgcj.dylib(libgcj.6.0.0.dylib-master.o) definition of _sqrt
/usr/lib/libm.dylib(sqrt970.o) definition of _sqrt
~/temp/gcj_stuff $ ls -l
total 344
-rw-r--r-- 1 john john 14126 21 Jul 18:47 TestAWT.java
-rwxr-xr-x 1 john john 156620 21 Jul 21:40 baz2*
~/temp/gcj_stuff $ otool -L baz2
baz2:
/usr/local/gcc_cvs/lib/libgcc_s.1.0.dylib (compatibility
version 1.0.0, current version 1.0.0)
/usr/local/gcc_cvs/lib/libgcj.6.dylib (compatibility version
7.0.0, current version 7.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0,
current version 71.1.1)
/usr/lib/libiconv.2.dylib (compatibility version 5.0.0, current
version 5.0.0)
/usr/lib/libmx.A.dylib (compatibility version 1.0.0, current
version 47.0.0)
~/temp/gcj_stuff $ ./baz2
false
true
-- listing properties --
path.separator=:
java.vm.name=GNU libgcj
awt.toolkit=gnu.java.awt.peer.gtk.GtkToolkit
java.vm.specification.name=Java(tm) Virtual Machine Specification
java.home=/usr/local/gcc_cvs
java.vm.specification.version=1.0
line.separator=
java.vm.specification.vendor=Sun Microsystems Inc.
gnu.classpath.home.url=file:///usr/local/gcc_cvs/lib
gnu.gcj.progname=./baz2
java.specification.version=1.3
java.library.path=
gnu.classpath.vm.shortname=libgcj
java.class.version=46.0
java.specification.name=Java(tm) Platform API Specification
os.version=7.4.0
gnu.classpath.home=/usr/local/gcc_cvs
user.home=/Users/john
file.encoding=US-ASCII
os.name=Darwin
user.name=john
java.class.path=/usr/local/gcc_cvs/share/java/libgcj-...
java.io.tmpdir=/tmp
os.arch=Power Macintosh
java.fullversion=GNU libgcj 3.5.0 20040718 (experimental)
user.language=en
java.specification.vendor=Sun Microsystems Inc.
user.dir=/Users/john/temp/gcj_stuff
java.vm.info=GNU libgcj 3.5.0 20040718 (experimental)
java.version=3.5.0
java.ext.dirs=/usr/local/gcc_cvs/share/java/ext
sun.boot.class.path=/usr/local/gcc_cvs/share/java/libgcj-...
java.vm.vendor=Free Software Foundation, Inc.
java.vendor.url=http://gcc.gnu.org/java/
java.vendor=Free Software Foundation, Inc.
file.separator=/
java.vm.version=3.5.0 20040718 (experimental)
gnu.cpu.endian=big
user.region=US
Thanks for any insights,
---J
More information about the Java
mailing list