Compilation of 2-classes program. Help!

Alexandre Petit-Bianco
Tue Sep 12 12:36:00 GMT 2000

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
> 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 -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
  /tmp/ccK5oOIU.o: In function `Raport::main(JArray<java::lang::String *> *)':
  /home/apbianco/tmp/ 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
  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
  apbianco@kazmo[~/tmp]: gcj -c 
  apbianco@kazmo[~/tmp]: gcj Raport.o Info.o --main=Raport -o raport
  apbianco@kazmo[~/tmp]: ./raport
  Here is the infosome info


More information about the Java mailing list