Compiling SWT application with GNU gcj

Andrew Haley aph@redhat.com
Tue Oct 11 09:50:00 GMT 2005


Andrea writes:
 > Hi all,
 > I'm trying to compile a simple SWT application (nothing more than a demo
 > app) with gcj but I'm having some problems in the linking phase.
 > 
 > This is what I do to compile:
 > 
 > -----------------------------------
 > nivox@host:~/Test/$ gcj -fjni -c --classpath=$SWT_HOME/swt.jar
 > test/swt/Test.java
 > 
 > nivox@host:~/Test/$ ls
 > test Test.o
 > 
 > nivox@host:~/Test/$ gcj --main=Test ./Test.o -lswt-gtk-3138
 > /tmp/ccf5eyYv.o(.text+0x12): In function `main':
 > : undefined reference to `_Jv_Compiler_Properties'
 > /tmp/ccf5eyYv.o(.text+0x2b): In function `main':
 > : undefined reference to `Test::class$'
 > /tmp/ccf5eyYv.o(.text+0x30): In function `main':
 > : undefined reference to `JvRunMain'
 > ./Test.o(.text+0x10): In function `test::swt::Test::main(JArray*)':
 > : undefined reference to `_Jv_InitClass'
 > ./Test.o(.text+0x1f): In function `test::swt::Test::main(JArray*)':
 > : undefined reference to `org::eclipse::swt::widgets::Display::class$'
 > ./Test.o(.text+0x24): In function `test::swt::Test::main(JArray*)':
 > : undefined reference to `_Jv_AllocObjectNoFinalizer'
 > ./Test.o(.text+0x2e): In function `test::swt::Test::main(JArray*)':
 > : undefined reference to
 > `org::eclipse::swt::widgets::Display::Display[in-charge]()'
 > ./Test.o(.text+0x42): In function `test::swt::Test::main(JArray*)':
 > : undefined reference to `org::eclipse::swt::widgets::Shell::class$'
 > ./Test.o(.text+0x47): In function `test::swt::Test::main(JArray*)':
 > : undefined reference to `_Jv_AllocObjectNoFinalizer'
 > ...
 > -----------------------------------
 > 
 > I have compiled with success a java program without graphic... so gcj is
 > supposed to work properly.
 > 
 > Gcj --version return this:
 > gcj-4.0 (GCC) 4.0.0 20050301 (prerelease) (Debian 4.0-0pre6ubuntu7)
 > 
 > I have the same problem on another machine with gcj 4.0.2 from Debian
 > unstable (ppc).
It looks to me like something isn't installed properly. gcj should
automatically find libgcj.so, which is where _Jv_InitClass and
suchlike are to be found. I'm guessing it's something crazy, like
libgcj is in the wrong place or maybe even missing.
But try your non-graphic Java program, and then do "ldd <progname>" to
see where libgcj is installed. Then try your compilation again with
"gcj -v". Tell us what you find.
Andrew.


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /