Problem linking java program
Mark Wielaard
mark@klomp.org
Thu Nov 10 13:20:00 GMT 2005
On Thu, 2005-11-10 at 14:06 +0100, Julien Claassen wrote:
> Hello all!
> I wanted to compile a helloworld program with selfcompiled gcc-3.4.3 (see
> below for more info). It had linking problems. Compile only works fine.
> The program was:
> // Begin of Test.java
>
> import java.lang.*;
>
> class Test
> {
> public static void main(String args[])
> {
> System.out.println("Hello world.\n");
> }
> };
>
> // EOF
> The gcj call and output was:
> gcj Test.java
>
> /usr/lib/crt1.o: In function `_start':
> /usr/lib/crt1.o(.text+0x18): undefined reference to `main'
> collect2: ld returned 1 exit status
When generating an executable you need it to tell which class is the
main class: gcj --main=Test Test.java
The resulting a.out executable will then start executing your program
using Test.main().
See also http://gcc.gnu.org/onlinedocs/gcj/Linking.html#Linking
Cheers,
Mark
--
Escape the Java Trap with GNU Classpath!
http://www.gnu.org/philosophy/java-trap.html
Join the community at http://planet.classpath.org/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://gcc.gnu.org/pipermail/java/attachments/20051110/c6a8e32c/attachment.sig>
More information about the Java
mailing list