Linking errors with gjc

James Shaw js102@ecs.soton.ac.uk
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:
helloworld.java
---------------
import java.io.*;
class helloworld {
 public static void main(String[] arg) {
 int i = 0;
 while (i < 10) {
 System.out.println(i);
 i++;
 }
 }
}
----------------
Have have played aroudn with gcj, and find running it like this (sort of)
works:
gcj -femit-class-files --main=helloworld helloworld.java
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/helloworld.java(.data+0xc): undefined
reference to `helloworld::main(JArray<java::lang::String *> *)'
/home/jshaw/university/gjctests/helloworld.java(.data+0x1c): 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:
0
1
10
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

AltStyle によって変換されたページ (->オリジナル) /