Bug 15919 - gcc for java is missing some libraries
gcc for java is missing some libraries
Status: CLOSED NOTABUG
Product: Red Hat Linux
Classification: Retired
Component: gcc (Show other bugs)
7.0
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2000-08-10 09:28 EDT by mal
Modified: 2008-05-01 11:37 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2000-08-15 11:45:13 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description mal 2000-08-10 09:28:05 EDT
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 10:33:44 EDT
Do you have libgcj installed?
Comment 2 mal 2000-08-10 10:39:19 EDT
Yes, I have

rpm -q libgcj libgcj-devel
libgcj-2.96-20
libgcj-devel-2.96-20
Comment 3 mal 2000-08-10 10:45:21 EDT
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 10:55:21 EDT
Make sure you pass it --main=HelloWorld option, see Java FAQ at
http://sources.redhat.com/
Comment 5 mal 2000-08-10 11:04:05 EDT
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 11:14:26 EDT
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 11:45:06 EDT
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.