Re: Problem linking java program

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In Nov 10 A.D. 2005 Michael Koch scripsit:

> On Thu, Nov 10, 2005 at 02:06:34PM +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
> >   I tried gcc, which gave some additional info:
> > gcc Test.java
>
> use this:
>
> gcj --main=Test Test.java -o test
  Will
gcj --main=Test -c Test.java
  Then generate code, that can be interpreted with gij?
  Thanks for this solution so far!
  Kindest regards
          Julien
>
> That is all well described in the gcj documentation.
>
>
> Cheers,
> Michael
> >
> > /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
> >
>
> --
> Escape the Java Trap with GNU Classpath!
> http://www.gnu.org/philosophy/java-trap.html
>
> Join the community at http://planet.classpath.org/
>

--------
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

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux