This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Problem with main routine during linking


Hi!

Try this:

$ cat hello.java
public class hello
{
 public static void main(String[] args)
    {
     System.out.println("Hello World ");
    }
}

$ gcj -o hello --main=hello hello.java
$ ./hello
Hello World 

Good!

$ gcj -o hello --main=hello hello.java -lg2c
/tmp/ccZQFVtjmain%O: In function `main':
/tmp/cc37HWSCmain.i(.text+0x0): multiple definition of `main'
/sw/gcc-3/lib/gcc-lib/i686-pc-linux-gnu/3.0/libg2c.a(main.o): \
   /home/kahlert/LOCAL/gcc-20010430/obj/i686-pc-linux-gnu/libf2c/libF77/../../../../libf2c/libF77/main.c:54:
first defined here
/sw/gcc-3/lib/gcc-lib/i686-pc-linux-gnu/3.0/../../../../i686-pc-linux-gnu/bin/ld:
Warning: size of symbol `main' changed from 58 to 42 in /tmp/ccZQFVtjmain%O
/sw/gcc-3/lib/gcc-lib/i686-pc-linux-gnu/3.0/libg2c.a(main.o): In function
`main':
/home/kahlert/LOCAL/gcc-20010430/obj/i686-pc-linux-gnu/libf2c/libF77/../../../../libf2c/libF77/main.c:61:
undefined reference to `MAIN__'
collect2: ld returned 1 exit status

Not so good.

The problem is that gcj puts the main function (i.e. the object containing
the main routine) after all user command line options in the link step.
I would propose to put it in front of it as the first object (after crtbegin
and friends).
So you can link to libraries containing main function dummies (like g77's libg2c).

Is there any problem with that?
Unfortunately, i do not know, where this linking actually happens and which
file i have to look at to change that.

Thanks for any opinions and help in advance,
Martin.

(This is gcc-20010430 snapshot)

-- 
The early bird gets the worm. If you want something else for       
breakfast, get up later.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]