From owner-freebsd-java@FreeBSD.ORG Thu Feb 28 00:32:54 2013 Return-Path: Delivered-To: freebsd-java@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 18718E37 for ; Thu, 28 Feb 2013 00:32:54 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from hammer.pct.niksun.com (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) by mx1.freebsd.org (Postfix) with ESMTP id B0679D29; Thu, 28 Feb 2013 00:32:53 +0000 (UTC) Message-ID: <512EA53D.8000000@FreeBSD.org> Date: Wed, 27 Feb 2013 19:30:53 -0500 From: Jung-uk Kim User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:17.0) Gecko/20130220 Thunderbird/17.0.3 MIME-Version: 1.0 To: Guy Helmer Subject: Re: Does gcj work? References: In-Reply-To: X-Enigmail-Version: 1.5.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: freebsd-java@freebsd.org X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Feb 2013 00:32:54 -0000 -----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 to continue, or q 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 > , 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 , > 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 , 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-----