Linking errors with gjc

James Shaw
Thu Oct 10 01:23:00 GMT 2002

I am running Red Hat Linux 7.3, gcc 2.96

I'm a newbie to Java, I have installed gcj, libgcj and libgcj-devel RPMs,
and I'm experienced problems with my first java program.
The code is this:

class helloworld {
  public static void main(String[] arg) {
    int i = 0;
    while (i < 10) {


Have have played aroudn with gcj, and find running it like this (sort of)
gcj -femit-class-files --main=helloworld

The helloworld.class file is created, but the following errors are reported:

/tmp/ccCw5ZuY.o: In function `global constructors keyed to helloworld
virtual table':
/home/jshaw/university/gjctests/ undefined
reference to `helloworld::main(JArray<java::lang::String *> *)'
/home/jshaw/university/gjctests/ undefined
reference to `helloworld::helloworld(void)'
collect2: ld returned 1 exit status

It is possible to run the program by calling "gij helloworld", but the
output I get is this:

What happened to 2-9?!  If anyone could let me know if my code is at fault,
or if I am using GCJ improperly, I would be grateful.

Thanks in advance,
James Shaw

More information about the Java mailing list