Problem linking java program

Julien Claassen julien@c-lab.de
Thu Nov 10 13:06:00 GMT 2005


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
 I tried gcc, which gave some additional info:
gcc Test.java
/usr/lib/crt1.o: In function `_start':
/usr/lib/crt1.o(.text+0x18): undefined reference to `main'
/tmp/ccq72aMH.o: In function `Test::main(JArray<java::lang::String*>*)':
/tmp/ccq72aMH.o(.text+0x8): undefined reference to `java::lang::System::class$'
/tmp/ccq72aMH.o(.text+0x1b): undefined reference to `_Jv_InitClass'
/tmp/ccq72aMH.o(.text+0x28): undefined reference to `java::lang::System::class$'
/tmp/ccq72aMH.o(.text+0x2d): undefined reference to `_Jv_InitClass'
/tmp/ccq72aMH.o(.text+0x37): undefined reference to `java::lang::System::out'
/tmp/ccq72aMH.o: In function `Test::Test()':
/tmp/ccq72aMH.o(.text+0x5f): undefined reference to `java::lang::Object::Object()'
/tmp/ccq72aMH.o(.data+0x50): undefined reference to `java::lang::Object::finalize()'
/tmp/ccq72aMH.o(.data+0x54): undefined reference to `java::lang::Object::hashCode()'
/tmp/ccq72aMH.o(.data+0x58): undefined reference to `java::lang::Object::equals(java::lang::Object*)'
/tmp/ccq72aMH.o(.data+0x5c): undefined reference to `java::lang::Object::toString()'
/tmp/ccq72aMH.o(.data+0x60): undefined reference to `java::lang::Object::clone()'
/tmp/ccq72aMH.o(.data+0xa0): undefined reference to `vtable for java::lang::Class'
/tmp/ccq72aMH.o(.data+0xb4): undefined reference to `java::lang::Object::class$'
/tmp/ccq72aMH.o(.eh_frame+0x11): undefined reference to `__gcj_personality_v0'
collect2: ld returned 1 exit status
My gcc was compiled with this config:
gcc -v
Reading specs from /usr/local/gcc343/lib/gcc/i686-pc-linux-gnu/3.4.3/specs
Configured with: ../gcc-3.4.3/configure --prefix=/usr/local/gcc343 --enable-threads=posix --enable-__cxa_atexit --enable-version-specific-runtime-libs --enable-languages=c,c++,f77,objc,java --enable-gather-detailed-mem-stats --enable-nls --with-included-gettext --enable-interpreter --enable-libgcj-multifile --with-x --enable-java-awt=xlib
Thread model: posix
gcc version 3.4.3
 I've got an i686 athlon (k7) machine with SuSE 8.1 glibc-2.2.5 (the crt1.o
is in that package).
 I looked into the crt1.o with nm, here's the small output:
nm /usr/lib/crt1.o
00000004 R _IO_stdin_used
00000000 D __data_start
 U __libc_start_main
 U _fini
00000000 R _fp_hw
 U _init
00000000 T _start
00000000 W data_start
 U main
 Can anyone help me? Did I forget to install/update something? How about
environment variables anything SPECIAL I need?
 Kindest regards and thanks for any help
 Julien
--------
Music was my first love and it will be my last (John Miles)
======== FIND MY WEB-PROJECT AT: ========
http://ltsb.sourceforge.net - the Linux TextBased Studio guide


More information about the Java mailing list

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