compile against library needs classes?!
gcj@stuellenberg.de
gcj@stuellenberg.de
Thu Sep 11 15:29:00 GMT 2003
Hello all,
I hope, I don't bother you with an already frequently asked question,
but I've not found an answer...
How is it possible to compile a native executable with gcj from a
.java file with an reference to another (but already compiled as an
DSO/static lib) Java class?
To speak, let me give the following example:
<<<---HW_lib.java--->>>
public class HW_lib {
public static int foo = 0;
}
<<<----------------->>>
<<<---HelloWorld.java--->>>
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Test: "+HW_lib.foo);
}
}
<<<--------------------->>>
Now I do
gcj -shared HW_lib.java -o libhw.so
and get a shared library.
Now I want to do
gcj --main=HelloWorld -o HelloWorld HelloWorld.java libhw.so
but that does not work:
HelloWorld.java: In class `HelloWorld':
HelloWorld.java: In method `HelloWorld.main(java.lang.String[])':
HelloWorld.java:3: error: Undefined variable or class name: `HW_lib.foo'.
System.out.println("Test: "+HW_lib.foo);
^
1 error
If I add the HW_lib.[class|java] to the classpath, everything works.
What I'm doing wrong here, or is it impossible to do so?
Regards,
Christian
More information about the Java
mailing list