LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 12-15-2006, 01:45 PM   #1
SW-ANIKY
LQ Newbie
 
Registered: Dec 2006
Posts: 13

Rep: Reputation: 0
Gcj undefined reference main (hello world program)


Hello all, i have a problem compiling my first program of java in slackware 11.0
The program (hola=hello, mundo=world(in spanish))

filename(holamundo.java)

public class holamundo
{
public static void main(String argv[])
{
System.out.println("hola mundo");
}
}

gcj holamundo.java -o hola
/usr/lib/gcc/i486-slackware-linux/3.4.6/../../../crt1.o(.text+0x18):
In function "_start":../sysdeps /i386/elf/start.S:115:undefined reference to 'main'
collect2:ld returned 1 exit status

THANKS.

I am just starting programing in java and linux, i have manuals about java but no one about java in linux, if someone knows about one, i will be very grateful.
 
Old 12-16-2006, 10:08 AM   #2
SW-ANIKY
LQ Newbie
 
Registered: Dec 2006
Posts: 13

Original Poster
Rep: Reputation: 0
4.1 Why do I get undefined reference to `main' errors?

When using gcj to link a Java program, you must use the --main= option to indicate the class that has the desired main method. This is because every Java class can have a main method, thus you have to tell gcj which one to use.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting undefined reference to main error?? Mistro116@yahoo.com Programming 14 07-29-2011 08:28 AM
Undefined reference, why? george_mercury Programming 4 05-07-2009 12:15 AM
Undefined reference in C++ program Komakino Programming 3 12-03-2006 04:42 PM
undefined reference to main cjbrockwell Programming 3 09-06-2006 05:09 PM
emacs 77: undefined reference to `main' creznedmick Programming 2 09-16-2003 07:46 PM


All times are GMT -5. The time now is 08:04 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration