Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Feb 2013 19:30:53 -0500
From:      Jung-uk Kim <jkim@FreeBSD.org>
To:        Guy Helmer <guy.helmer@gmail.com>
Cc:        freebsd-java@freebsd.org
Subject:   Re: Does gcj work?
Message-ID:  <512EA53D.8000000@FreeBSD.org>
In-Reply-To: <CA%2B537dG3Z2=N=qMKg5ujg03diq6V=Z9O_Hy4z_4hb_ON-tSqfg@mail.gmail.com>
References:  <CA%2B537dG3Z2=N=qMKg5ujg03diq6V=Z9O_Hy4z_4hb_ON-tSqfg@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 2013-02-27 17:45:54 -0500, Guy Helmer wrote:
> I have been trying to get HelloWorld.java to work when compiled
> with gcj47 on both i386 and amd64. Seems like it should work. This
> code:
> 
> public class HelloWorld { public static void main(String[] args) { 
> System.out.println("Hello, World!"); } }
> 
> compiled thus: redwater:~ (515) gcj47 --main=HelloWorld -o
> HelloWorld HelloWorld.java
> 
> always croaks: redwater:~ (516) ./HelloWorld Abort (core dumped)
> 
> redwater:~ (517) gdb751 HelloWorld HelloWorld.core ... (gdb) where 
> #0  0x2a4b573b in thr_kill () from /lib/libc.so.7 #1  0x2a42f986 in
> ?? () from /lib/libthr.so.3 #2  0x2a43005b in raise () from
> /lib/libthr.so.3 #3  0x2a55e04a in abort () from /lib/libc.so.7 #4
> 0x28b4b08f in _Jv_Throw (value=0xbfbfd894) at
> ../.././../gcc-4.7-20130119/libjava/exception.cc:128 #5  0x28b892a8
> in java::lang::Class::forName (className=0x844b9c0, initialize=1
> '\001', loader=0x0) at
> ../.././../gcc-4.7-20130119/libjava/java/lang/natClass.cc:108 #6
> 0x28b9ac67 in java.lang.Class.forName(java.lang.String, 
> java.lang.Class)java.lang.Class (className=@844b9c0,
> caller=@29fb6c80) at
> ../.././../gcc-4.7-20130119/libjava/java/lang/Class.java:133 #7
> 0x28fd457e in java.net.URLClassLoader.addURLImpl(java.net.URL)void
> ( this=this@entry=@845afa0, newUrl=newUrl@entry=@8449c80) at 
> /usr/ports/lang/gcc47/work/gcc-4.7-20130119/libjava/classpath/java/net/URLClassLoader.java:332
>
> 
#8  0x28fd4c83 in java.net.URLClassLoader.addURL(java.net.URL)void
> (this=@845afa0, newUrl=@8449c80) at 
> /usr/ports/lang/gcc47/work/gcc-4.7-20130119/libjava/classpath/java/net/URLClassLoader.java:281
>
> 
#9  0x28ba83e4 in gnu.gcj.runtime.SystemClassLoader.init()void
> (this=@845afa0) at 
> /usr/ports/lang/gcc47/work/gcc-4.7-20130119/libjava/gnu/gcj/runtime/SystemClassLoader.java:89
>
> 
- ---Type <return> to continue, or q <return> to quit---
> #10 0x28babed5 in
> gnu.gcj.runtime.ExtensionClassLoader.initialize()void () at 
> /usr/ports/lang/gcc47/work/gcc-4.7-20130119/libjava/gnu/gcj/runtime/ExtensionClassLoader.java:33
>
> 
#11 0x28b3f600 in _Jv_CreateJavaVM (vm_args=vm_args@entry=0x0)
> at ../.././../gcc-4.7-20130119/libjava/prims.cc:1670 #12 0x28b3fb38
> in _Jv_RunMain (vm_args=0x0, klass=klass@entry=0x8049240
> <HelloWorld::class$>, name=name@entry=0x0, argc=argc@entry=1,
> argv=argv@entry=0xbfbfdb98, is_jar=is_jar@entry =false) at
> ../.././../gcc-4.7-20130119/libjava/prims.cc:1720 #13 0x28b3fea2 in
> _Jv_RunMain (klass=klass@entry=0x8049240 <HelloWorld::class$>, 
> name=name@entry=0x0, argc=argc@entry=1,
> argv=argv@entry=0xbfbfdb98, is_jar=is_jar@entry=false) at 
> ../.././../gcc-4.7-20130119/libjava/prims.cc:1815 #14 0x28b3ff3b in
> JvRunMain (klass=0x8049240 <HelloWorld::class$>, argc=1, 
> argv=0xbfbfdb98) at
> ../.././../gcc-4.7-20130119/libjava/prims.cc:1821 #15 0x08048ad9 in
> main ()
> 
> Any ideas?

It works.  You just missed a very important option:

% gcj48 --main=HelloWorld -o HelloWorld HelloWorld.java
Abort (core dumped)
% ./HelloWorld
% gcj48 --main=HelloWorld -Wl,-rpath=/usr/local/lib/gcc48 -o
HelloWorld HelloWorld.java
% ./HelloWorld
Hello, World!

As you can see, you had to add "-Wl,-rpath=/usr/local/lib/gcc48" (or
"-Wl,-rpath=/usr/local/lib/gcc47" in your case).

Jung-uk Kim
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.19 (FreeBSD)

iQEcBAEBAgAGBQJRLqU9AAoJECXpabHZMqHOnNoH/ih5dkcrP5EHdeKuTA03EUC7
QbyvcWIVGFMIlceUTJfdypaO2QaqeN8w83PX+BLBgkWH+g/8yXnkfIc1J/uMd1zT
e7UO5pozWH/KDI+tWDjz4T7M/wM61CgPsgNaOgYXx85kE4m8NakxF+DBizCMfid5
5FYTfX+Fq5xpD0Nq5iJeweVjbyqHSJVyHcED4+RXxOoKXjWPlfv9w48r0mpJrIY4
lQCcmZdan1v2WecDHaYvOIJVxGqdPIfx5oZymz61EV9crEZg5ewvSW70gQOkVUc7
AepQoTIb9WnDPZoWuljCBLGQzccERRlpD/5qaLK0SWQ5dG4ajg53aVM4ociTpwk=
=16+x
-----END PGP SIGNATURE-----



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?512EA53D.8000000>