Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 12-15-2006, 01:45 PM   #1
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))


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

gcj -o hola
In function "_start":../sysdeps /i386/elf/start.S:115:undefined reference to 'main'
collect2:ld returned 1 exit status


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
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.


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting undefined reference to main error?? 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 > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:51 PM.

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