Bug 15919 - gcc for java is missing some libraries
Summary: gcc for java is missing some libraries
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gcc
Version: 7.0
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2000-08-10 13:28 UTC by mal
Modified: 2008-05-01 15:37 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2000-08-15 15:45:13 UTC
Embargoed:


Attachments (Terms of Use)

Description mal 2000-08-10 13:28:05 UTC
I can compile .java file without problem:
gcc -c Y.java 
and Y.o file is created.

But when trying to create executable (no -c)
gcc Y.java 
I get:
/usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../crt1.o: In function
`_start':
/usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../crt1.o(.text+0x18):
undefined reference to `main'
/tmp/ccKn35ww.o: In function `Y::Y(void)':
/tmp/ccKn35ww.o(.text+0xe): undefined reference to
`java::lang::Object::Object(void)'
/tmp/ccKn35ww.o: In function `Y::main(JArray<java::lang::String *> *)':
/tmp/ccKn35ww.o(.text+0x28): undefined reference to
`_CL_Q34java4lang6System'
/tmp/ccKn35ww.o(.text+0x3c): undefined reference to `_Jv_InitClass'
/tmp/ccKn35ww.o(.text+0x4d): undefined reference to
`_CL_Q34java4lang6System'
/tmp/ccKn35ww.o(.text+0x52): undefined reference to `_Jv_InitClass'
/tmp/ccKn35ww.o(.text+0x5e): undefined reference to
`java::lang::System::err'
/tmp/ccKn35ww.o: In function `global constructors keyed to Y::Y(void)':
/tmp/ccKn35ww.o(.text+0x93): undefined reference to `_Jv_RegisterClass'
/tmp/ccKn35ww.o(.data+0x38): undefined reference to
`java::lang::Object::finalize(void)'
/tmp/ccKn35ww.o(.data+0x3c): undefined reference to
`java::lang::Object::hashCode(void)'
/tmp/ccKn35ww.o(.data+0x40): undefined reference to
`java::lang::Object::equals(java::lang::Object *)'
/tmp/ccKn35ww.o(.data+0x44): undefined reference to
`java::lang::Object::toString(void)'
/tmp/ccKn35ww.o(.data+0x48): undefined reference to
`java::lang::Object::clone(void)'
/tmp/ccKn35ww.o(.data+0x60): undefined reference to `java::lang::Class
virtual table'
/tmp/ccKn35ww.o(.data+0x74): undefined reference to
`_CL_Q34java4lang6Object'
collect2: ld returned 1 exit status

Comment 1 Bill Nottingham 2000-08-10 14:33:44 UTC
Do you have libgcj installed?

Comment 2 mal 2000-08-10 14:39:19 UTC
Yes, I have

rpm -q libgcj libgcj-devel
libgcj-2.96-20
libgcj-devel-2.96-20


Comment 3 mal 2000-08-10 14:45:21 UTC
In addition:
This is the file HelloWorld.java 
I am trying to compile:
---
public class HelloWorld {
public static void main(String [] args)
{
 System.err.println("Hello, World");
}
}
---

Comment 4 Jakub Jelinek 2000-08-10 14:55:21 UTC
Make sure you pass it --main=HelloWorld option, see Java FAQ at
http://sources.redhat.com/

Comment 5 mal 2000-08-10 15:04:05 UTC
GCC does not work with --main
gcc --main=HelloWorld HelloWorld.java 
jc1: Unrecognized option `-fmain=HelloWorld'

and gcj does not work at all because 
of bug http://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=15349

Comment 6 Jakub Jelinek 2000-08-10 15:14:26 UTC
You have to use gcj.

The bug you mentioned has been fixed since then, for now just add

libgcj.spec by hand:

[jakub@pork 2.96]$ cd /usr/lib/gcc-lib/i386-redhat-linux/2.96/

[jakub@pork 2.96]$ cat libgcj.spec

#

# This spec file is read by gcj when linking.

# It is used to specify the standard libraries we need in order

# to link with libgcj.

#

%rename lib liborig

*lib: -lgcj -lm -lgcjgc -lpthread -lzgcj   -ldl %(liborig)



*jc1:  -fno-use-divide-subroutine  -fasynchronous-exceptions



#

# libgcc should really be a shared library.  This is a design flaw

# that causes no end of mysterious problems.  If we are using the

# GNU linker, force parts of libgcc into the program file rather

# than picking bits up from various shared libraries.

#

%rename startfile startfileorig

*startfile: %(startfileorig)  -u __rethrow -u __frame_state_for -lgcc



Comment 7 Preston Brown 2000-08-15 15:45:06 UTC
so this is fixed jakub?  If so, please close.


Note You need to log in before you can comment on or make changes to this bug.