This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: gcj Newbie Question
- From: Michael Koch <konqueror at gmx dot de>
- To: java at gcc dot gnu dot org
- Cc: "Kyle Kinkaid" <kkinkaid at ucsc dot edu>
- Date: Fri, 27 Aug 2004 07:15:13 +0200
- Subject: Re: gcj Newbie Question
- References: <web-5378290@tin.ucsc.edu>
Am Freitag, 27. August 2004 06:58 schrieb Kyle Kinkaid:
> 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
This should work:
gcj -I. -o Trypackage --main=TryPackage TryPackage.java
Geometry/Point.java Geometry/Line.java
You need to speficy all classes you need to link. Otherwise gcj will
not use them.
Michael