LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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
  Search this Thread
Old 12-18-2007, 01:39 PM   #1
SW-ANIKY
LQ Newbie
 
Registered: Dec 2006
Posts: 13

Rep: Reputation: 0
gcj undefined reference to error


I have this error when trying to compile this:


//Libreta.java file.
import aniky.Vector;

public class Libreta {
public static void main(String[] args) {
new Vector();

}

}

--------------------------------------------------------------------
//other file Vector.class

package aniky;

public class Vector {
public Vector() {
System.out.println("euieuior");
}
}

//compiled to .class file: gcj -C Vector.java
-----------------------------------------------------------------
when: gcj --main=Libreta Libreta.java -o lib
It complains with undefined reference to Vector etc.

If only import the file no complains. If the import is from the default library no complains.

Is a very simple test, but i dont know what i am doing wrong. I have the gcj that comes with sw 12. version 4.something
 
Old 12-18-2007, 07:10 PM   #2
jeffschwab
LQ Newbie
 
Registered: May 2007
Posts: 8

Rep: Reputation: 0
AFAIK, you have to list the bytecode files explicitly for gcj if you want to produce native object code:

gcj --main=Libreta Libreta.java aniky/Vector.class -o lib

If you just want class files, there is no such restriction:

$ gcj -C Libreta.java
$ java Libreta
euieuior
 
Old 12-19-2007, 11:00 AM   #3
SW-ANIKY
LQ Newbie
 
Registered: Dec 2006
Posts: 13

Original Poster
Rep: Reputation: 0
That answer was just perfect. Thanks.
 
  


Reply



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
Undefined reference error jacques83 Programming 20 04-11-2013 07:23 AM
undefined reference error ilnli Programming 2 08-02-2007 08:34 PM
Gcj undefined reference main (hello world program) SW-ANIKY Programming 1 12-16-2006 10:08 AM
undefined reference error bahadur Programming 5 07-25-2006 09:18 PM
undefined reference error Quest101 Programming 3 01-01-2005 12:27 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration