[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[sid] gcj native compilation question



Hello!

With gcj-3.3.3pre on Debian sid, I tried a native compilation of some java 
code. I wanted to find out how .so files are handled by gcj.

Here's the short source code, just two tiny files:

-- Lib.java --
public class Lib {

    public static void yipe() {
        System.out.println("Library function yipe used");
    }
}

-- Hello2.java --
public class Hello2 {

    public static void main(String[] args) {
        Lib.yipe();
        System.out.println("Hello World! - pure native");
    }
}
-----------------
Native Sun JDK/JRE compilation and execution works fine with:
javac Lib.java
javac -d . Hello2.java
java Hello2

Now with gcj:
First I generate the .o and .so files...

gcj -shared -I . -o libLib.so Lib.java
gcj -I . -o Lib.o -c Lib.java

this seems to work fine (no error). However,
gcj --main=Hello2 -I. -o Hello2 Hello2.o Lib.o
yields an error:

/tmp/cc6K1zTn.o(.text+0x2b): In function `main':
: undefined reference to `Hello2::class$'
collect2: ld returned 1 exit status

Hmm. Why would there be a reference to some .class file in native compilation 
mode?

Is there some kind of example for this? I was unable to find any in the gcj 
documentation.

Any help would be greatly appreciated.

-Malte Cornils

PS: Please Cc: me on replies, I'm accessing the slow web archive ATM.



Reply to: