This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
gcj Newbie Question
- From: "Kyle Kinkaid" <kkinkaid at ucsc dot edu>
- To: java at gcc dot gnu dot org
- Date: Thu, 26 Aug 2004 21:58:47 -0700
- Subject: gcj Newbie Question
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