* Unable to compile java file with gcj 4.1.1: undefined reference to main
@ 2007-02-27 5:51 Stephen Torri
2007-02-27 10:06 ` Andrew Haley
0 siblings, 1 reply; 3+ messages in thread
From: Stephen Torri @ 2007-02-27 5:51 UTC (permalink / raw)
To: GCC List
I am having trouble building a java file with gcj. If I attempt to build
it from the obfuscated class file (a.class) I get the error message:
storri@base$ gcj a.class
/usr/lib/gcc/i686-pc-linux-gnu/4.1.1/../../../crt1.o: In function `_start':
init.c:(.text+0x18): undefined reference to `main'
collect2: ld returned 1 exit status
So I though okay I will let gcj reading the straight Java source file. I
get the same error message. Given the source file below is there any
reason why GCJ cannot compile it?
Stephen
----------------------
class Fibonacci {
public int calculate ( int n )
{
int output = 0;
if ( n > 1 )
{
output = calculate ( n - 1 ) + calculate ( n - 2 );
}
else
{
output = n;
}
return output;
}
public static void main ( String[] inc )
{
if ( inc.length > 0 )
{
Fibonacci f_ref = new Fibonacci();
int n = Integer.parseInt(inc[0]);
while ( n != -1 )
{
System.out.println( "Calculated fibonacci number: " +
f_ref.calculate ( n ) );
n--;
}
}
return;
}
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Unable to compile java file with gcj 4.1.1: undefined reference to main
2007-02-27 5:51 Unable to compile java file with gcj 4.1.1: undefined reference to main Stephen Torri
@ 2007-02-27 10:06 ` Andrew Haley
2007-02-27 15:15 ` Stephen Torri
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Haley @ 2007-02-27 10:06 UTC (permalink / raw)
To: Stephen Torri; +Cc: GCC List
Stephen Torri writes:
> I am having trouble building a java file with gcj. If I attempt to build
> it from the obfuscated class file (a.class) I get the error message:
>
> storri@base$ gcj a.class
> /usr/lib/gcc/i686-pc-linux-gnu/4.1.1/../../../crt1.o: In function `_start':
> init.c:(.text+0x18): undefined reference to `main'
> collect2: ld returned 1 exit status
>
> So I though okay I will let gcj reading the straight Java source file. I
> get the same error message. Given the source file below is there any
> reason why GCJ cannot compile it?
Works for me:
zorro:~ $ gcj Fibonacci.java --main=Fibonacci
zorro:~ $ ./a.out 6
Calculated fibonacci number: 8
Calculated fibonacci number: 5
Calculated fibonacci number: 3
Calculated fibonacci number: 2
Calculated fibonacci number: 1
Calculated fibonacci number: 1
Calculated fibonacci number: 0
Andrew.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Unable to compile java file with gcj 4.1.1: undefined reference to main
2007-02-27 10:06 ` Andrew Haley
@ 2007-02-27 15:15 ` Stephen Torri
0 siblings, 0 replies; 3+ messages in thread
From: Stephen Torri @ 2007-02-27 15:15 UTC (permalink / raw)
To: Andrew Haley; +Cc: GCC List
On Tue, 2007-02-27 at 10:03 +0000, Andrew Haley wrote:
> Stephen Torri writes:
> > I am having trouble building a java file with gcj. If I attempt to build
> > it from the obfuscated class file (a.class) I get the error message:
> >
> > storri@base$ gcj a.class
> > /usr/lib/gcc/i686-pc-linux-gnu/4.1.1/../../../crt1.o: In function `_start':
> > init.c:(.text+0x18): undefined reference to `main'
> > collect2: ld returned 1 exit status
> >
> > So I though okay I will let gcj reading the straight Java source file. I
> > get the same error message. Given the source file below is there any
> > reason why GCJ cannot compile it?
>
> Works for me:
>
> zorro:~ $ gcj Fibonacci.java --main=Fibonacci
> zorro:~ $ ./a.out 6
> Calculated fibonacci number: 8
> Calculated fibonacci number: 5
> Calculated fibonacci number: 3
> Calculated fibonacci number: 2
> Calculated fibonacci number: 1
> Calculated fibonacci number: 1
> Calculated fibonacci number: 0
Ah. Thanks for the hint on using --main. I did not think to use that
since I never had to do that for a C/C++ program. Now I am back into to
business.
Stephen
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-02-27 15:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-27 5:51 Unable to compile java file with gcj 4.1.1: undefined reference to main Stephen Torri
2007-02-27 10:06 ` Andrew Haley
2007-02-27 15:15 ` Stephen Torri
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).