Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 9 Oct 2001 07:02:55 +1000
From:      "Jan Mikkelsen" <janm@transactionware.com>
To:        "John Utz" <john@utzweb.net>
Cc:        <java@FreeBSD.ORG>
Subject:   Re: Getting gcj to run on FreeBSD
Message-ID:  <013201c1503c$9b13f200$0a01a8c0@mosm1>
References:  <Pine.LNX.4.33.0110081556090.829-100000@jupiter.linuxengine.net>

next in thread | previous in thread | raw e-mail | index | archive | help
"John Utz" <john@utzweb.net> wrote:
> well, given my profound unfamiliarity with gjc....here goes nothin ' :-)

Thanks for the reply!

> On Tue, 9 Oct 2001, Jan Mikkelsen wrote:
>
> > "Jan Mikkelsen" <janm@transactionware.com> wrote:
> > > It builds fine, but a hello program either core dumps (with dynamic
> > linking)
> > > or fails to link with unresolved externals to
"java::util::List::class$".
>
> given that gjc is a java to native exe compiler, does it not follow that
> you would need a natively compiled libgjc that contains native
> implementations of the classes found in CLASSES.jar or does it expect to
> resolve dependencies via the java jar files?

I have a natively built gcj:

$ ls -l /pkgs/gcc-3.0.1/lib/libgcj*
-rw-r--r--  1 root  wheel  28589106 Aug 23 23:06
/pkgs/gcc-3.0.1/lib/libgcj.a
-rwxr-xr-x  1 root  wheel       789 Aug 23 23:06
/pkgs/gcc-3.0.1/lib/libgcj.la
lrwxr-xr-x  1 root  wheel        11 Aug 23 23:06
/pkgs/gcc-3.0.1/lib/libgcj.so -> libgcj.so.2
-rwxr-xr-x  1 root  wheel  25549610 Aug 23 23:06
/pkgs/gcc-3.0.1/lib/libgcj.so.2
-rw-r--r--  1 root  wheel       478 Aug 23 23:06
/pkgs/gcc-3.0.1/lib/libgcj.spec
-rw-r--r--  1 root  wheel      1524 Aug 23 23:06
/pkgs/gcc-3.0.1/lib/libgcjdata.a
-rw-r--r--  1 root  wheel    375732 Aug 23 23:08
/pkgs/gcc-3.0.1/lib/libgcjgc.a
-rwxr-xr-x  1 root  wheel       741 Aug 23 23:08
/pkgs/gcc-3.0.1/lib/libgcjgc.la
lrwxr-xr-x  1 root  wheel        13 Aug 23 23:08
/pkgs/gcc-3.0.1/lib/libgcjgc.so -> libgcjgc.so.1
-rwxr-xr-x  1 root  wheel    302291 Aug 23 23:08
/pkgs/gcc-3.0.1/lib/libgcjgc.so.1

I can see that it is being used because other symbols from libgcj are being
resolved during the static linking process.  This is the output from a
static compile:

$ /pkgs/gcc-3.0.1/bin/gcj -static --main=hello hello.java
/pkgs/gcc-3.0.1/lib/gcc-lib/i386-unknown-freebsd4.3/3.0.1/../../../libgcj.a(
Vector.o):/home/janm/Kits/gcc-3.0.1/libjava/java/util/Vector.java:232:
undefined reference to `java::util::List::class$'
/pkgs/gcc-3.0.1/lib/gcc-lib/i386-unknown-freebsd4.3/3.0.1/../../../libgcj.a(
AbstractList.o): In function
`java::util::AbstractList::equals(java::lang::Object*)':
/home/janm/Kits/gcc-3.0.1/libjava/java/util/AbstractList.java:88: undefined
reference to `java::util::List::class$'
/home/janm/Kits/gcc-3.0.1/libjava/java/util/AbstractList.java:91: undefined
reference to `java::util::List::class$'
/home/janm/Kits/gcc-3.0.1/libjava/java/util/AbstractList.java:91: undefined
reference to `java::util::List::class$'
/home/janm/Kits/gcc-3.0.1/libjava/java/util/AbstractList.java:95: undefined
reference to `java::util::List::class$'
/pkgs/gcc-3.0.1/lib/gcc-lib/i386-unknown-freebsd4.3/3.0.1/../../../libgcj.a(
AbstractList.o):/home/janm/Kits/gcc-3.0.1/libjava/java/util/AbstractList.jav
a:95: more undefined references to `java::util::List::class$' follow
collect2: ld returned 1 exit status

hello.java contains:

class hello {
    static void main(String[] args) {
        System.out.println("hello, world");
    }
}

> > Sorry to follow up my own message.  The unresolved externals happen with
> > static linking.
>
> static linking to what? it would seem to me that if there is a libgjc.a
> that it would have to be referenced in the link command line.... is it?

Yes.  From the gcj command line above, with the '-v' option added:

/pkgs/gcc-3.0.1/lib/gcc-lib/i386-unknown-freebsd4.3/3.0.1/collect2 -m
elf_i386 -V -Bstatic /usr/lib/crt1.o /usr/lib/crti.o
/pkgs/gcc-3.0.1/lib/gcc-lib/i386-unknown-freebsd4.3/3.0.1/crtbegin.o -u
data_start
/pkgs/gcc-3.0.1/lib/gcc-lib/i386-unknown-freebsd4.3/3.0.1/../../../libgcjdat
a.a -L/pkgs/gcc-3.0.1/lib/gcc-lib/i386-unknown-freebsd4.3/3.0.1 -L/pkgs/gcc-
3.0.1/lib/gcc-lib/i386-unknown-freebsd4.3/3.0.1/../../..
/var/tmp/ccKmRulPmain.o
/var/tmp/ccVHynhZ.o -lgcc -lgcj -lm -lgcjgc -lzgcj -lgcc -lc -lgcc
/pkgs/gcc-3.0.1/lib/gcc-lib/i386-unknown-freebsd4.3/3.0.1/crtend.o
/usr/lib/crtn.o

I am also seeing the same problem with the 20011001 snapshot on another
machine.  I suspect I've done something wrong during the gcc/gcj build
process, but "configure" and "gmake bootstrap" isn't really that complex.

Thanks,

Jan Mikkelsen



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-java" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?013201c1503c$9b13f200$0a01a8c0>