This is the mail archive of the
java-discuss@sourceware.cygnus.com
mailing list for the Java project.
Linking bug (?) and linking questions
- To: java-discuss at sourceware dot cygnus dot com
- Subject: Linking bug (?) and linking questions
- From: Korbinian Strimmer <korbinian dot strimmer at zoology dot oxford dot ac dot uk>
- Date: Mon, 7 Feb 2000 20:19:21 +0000 (GMT)
Hello!
I am currently trying to adapt PAL (my molbiol statistics
Java library, http//users.ox.ac.uk/~strimmer/pal) to make it
compile with gcj 2.95.2 and libgcj 2.95.1.
I had no trouble (after changing parts of the code) to compile
all objects into *.o. However, I have some trouble to link.
I have scanned through the archives of this mailing list but
I couldn't find answers so far.
Many thanks for your help,
Korbinian
==================================================================
1) Linking is not possible when object with main function is
part of a package (THIS MIGHT BE A BUG):
----------------- Sample.java -------
package test;
public class Sample
{
public static void main(String args[])
{
System.out.println("Hello!");
}
}
-------------------------------------
Compiles perfectly to Sample.class (given a proper location)
and to Compile.o but does not link:
cj -o sample --main=Sample Sample.o
gives
/tmp/cclHkUTcmain.o: In function `main':
/tmp/ccV6SswPmain.i(.text+0x12): undefined reference to `_CL_6Sample'
collect2: ld returned 1 exit status
However, if the package statement is left out then it does link!!!
This is a major problem for me because all my code/objects for
applications is in fact lying in a package.
==================================================================
2) Easier linking:
How can I avoid to specify the objects to be linked manually?
After all, the compiler does know by itself where the compiled
classes are (through CLASSPATH) and even gives me a list of
dependencies if I want?
Any tricks for that? (This would make life much easier because
bascially all objects in my library are to some degree related with
each other. Apart from that, the precise path where the objects
actually reside changes from system to system).
==================================================================
3) Maybe I can link versus the whole library? If so, how do I
link with gcj all my libary objects (that do not contain a
main function) together to one single file? Can this file be
used a shared library?
==================================================================
4) If I link objects files produced with gcj together gcj also seems
to include all the unnecessary code (e.g., if I add an object that
is not used anywhere). Is is a property of the linker in gcj, or
a general property of ld?
==================================================================