gcj Newbie Question

Kyle Kinkaid kkinkaid@ucsc.edu
Fri Aug 27 05:14:00 GMT 2004


Dear Sirs:

I am learning Java using the book "Beginning Java 2" by 
Ivor Horton (ed. SDK 1.4) and have been using gcj to do my 
compiling.  I have been successful up until Ch.5 (exercise 
"Testing the Geometry Package", p.219) where packages are 
taught.  When I compile, I get "undefined reference to..." 
errors (as shown below).

The file with the main() method is called TryPackage.java 
which references classes Point and Line.  Point.class and 
Line.class are stored in ./Geometry/.  I get the error 
when I use my code (as copied from the book) or the code 
that can be downloaded from the publisher's (Wrox) 
website.  When I use javac it compiles and runs fine. When 
I use gcj to goto byte code it runs fine (using java or 
gij).  Only when I try to go from a class to a native 
executable (or direct from source to an executable) to I 
get the above error messages.

$ gcj -I. -o Trypackage --main=TryPackage TryPackage.java
/tmp/ccuUHHTo.o(.text+0x1c3): In function 
`TryPackage::main(JArray<java::lang::String*>*)':
: undefined reference to `Geometry::Point::class$'
/tmp/ccuUHHTo.o(.text+0x218): In function 
`TryPackage::main(JArray<java::lang::String*>*)':
: undefined reference to `Geometry::Point::class$'
/tmp/ccuUHHTo.o(.text+0x2cf): In function 
`TryPackage::main(JArray<java::lang::String*>*)':
: undefined reference to 
`Geometry::Point::Point[in-charge](double, double)'
/tmp/ccuUHHTo.o(.text+0x301): In function 
`TryPackage::main(JArray<java::lang::String*>*)':
: undefined reference to `Geometry::Line::class$'
/tmp/ccuUHHTo.o(.text+0x367): In function 
`TryPackage::main(JArray<java::lang::String*>*)':
: undefined reference to `Geometry::Line::class$'
/tmp/ccuUHHTo.o(.text+0x3f2): In function 
`TryPackage::main(JArray<java::lang::String*>*)':
: undefined reference to 
`Geometry::Line::Line[in-charge](Geometry::Point*, 
Geometry::Point*)'
collect2: ld returned 1 exit status

(I am working with gcj v3.3.3 on a Fedora Core 2 box. If 
you would like any more information, I would be happy to 
provide it.) 

I am not exactly sure what I am doing wrong, but I would 
appreciate any help.  Thank you for your time and 
consideration, Kyle

----
Kyle Kinkaid
kkinkaid@ucsc.edu



More information about the Java mailing list