This is the mail archive of the
java-discuss@sources.redhat.com
mailing list for the Java project.
Re: Compilation of 2-classes program. Help!
- To: Przemyslaw Pokrywka <emo at 2com dot pl>
- Subject: Re: Compilation of 2-classes program. Help!
- From: Alexandre Petit-Bianco <apbianco at cygnus dot com>
- Date: Tue, 12 Sep 2000 12:36:51 -0700 (PDT)
- Cc: java-discuss at sourceware dot cygnus dot com
- References: <00091221264500.01951@emoHQ>
- Reply-To: apbianco at redhat dot com
Przemyslaw Pokrywka writes:
> How to compile program containig more than 1 class? When I tried to
> compile my simple 2-class program, I got following results:
> $ gcj --main=Raport -v -o raport Raport.java
> Reading specs from /usr/lib/gcc-lib/i386-linux/2.95.2/specs
> Reading specs from /usr/lib/libgcj.spec
> rename spec lib to liborig
> gcc version 2.95.2 20000220 (Debian GNU/Linux)
> /usr/lib/gcc-lib/i386-linux/2.95.2/jc1 Raport.java -quiet -g1 -version
> -o /tmp/ccSp2L3h.s
> GNU Java version 2.95.2 20000220 (Debian GNU/Linux) (i386-linux)
> compiled by GNU C version 2.95.2 20000220 (Debian GNU/Linux).
> gcj: Internal compiler error: program jc1 got fatal signal 11
This shouldn't happen. I can't reproduce the ICE with a recent version
of the compiler, you should try to build and install a more recent
snapshot of the compiler and the runtime libraries.
Otherwise, the command you used should result in a link error: the
class `Raport' relies on something provided by the class `Info' and
your command line doesn't specify that:
apbianco@kazmo[~/tmp]: gcj --main=Raport -o raport Raport.java
/tmp/ccK5oOIU.o: In function `Raport::main(JArray<java::lang::String *> *)':
/home/apbianco/tmp/Raport.java:5: undefined reference to `Info::getInfo(void)' collect2: ld returned 1 exit status
There are several ways to compile your application. For example, you
can specify everything in one command line, compiling (and linking)
all the file your application requires at once:
apbianco@kazmo[~/tmp]: gcj --main=Raport -o raport Raport.java Info.java
apbianco@kazmo[~/tmp]: ./raport
Here is the infosome info
Or (and this is more suited to the use of a Makefile) compile the
files one by one into objects and then link the objects together:
apbianco@kazmo[~/tmp]: gcj -c Raport.java
apbianco@kazmo[~/tmp]: gcj -c Info.java
apbianco@kazmo[~/tmp]: gcj Raport.o Info.o --main=Raport -o raport
apbianco@kazmo[~/tmp]: ./raport
Here is the infosome info
./A