LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: teddybear on November 18, 2005, 21:28:39

Title: GCJ again
Post by: teddybear on November 18, 2005, 21:28:39
Greetings!

Have there been any progress since this discussion:

http://lwjgl.org/forum/viewtopic.php?t=1165&postdays=0&postorder=asc&highlight=gcj&start=30

It seems like the "ghost in the shell" styled fix for GCJ did not make it to 0.98
Personally, I'm experiencing the same problems as Matzon did... Before embarking upon the quest myself, I just want to know if that broblem is related to proguard? Well, generally, has anyone made any progress in this?

IMHO, GCJ stuff is so important for us that maybe we should place a sticky topic to track the progress...

Michael.
Title: GCJ again
Post by: elias on November 19, 2005, 14:57:57
If we are to experiment with gcj, please leave out proguard, as it will only hinder debugging. That is, get it to work with gcj on ordinary class files, and then try proguard on them.

- elias
Title: GCJ again
Post by: teddybear on November 19, 2005, 20:47:51
I'm trying to compile lwjgl.jar like like that (simple):
gcj -c lwjgl.jar
and get:
org/lwjgl/J2SESysImplementation.java: In class `org.lwjgl.J2SESysImplementation':
org/lwjgl/J2SESysImplementation.java: In method `org.lwjgl.J2SESysImplementation.alert(java.lang.String,java.lang.String)':
org/lwjgl/J2SESysImplementation.java:52: error: cannot find file for class javax.swing.UIManager
etc....

Well, the class J2SESysImplementation exists in lwjgl.jar (v0.98 ) and is really packed with references to javax.swing.* .... :-) As we all know, libgcj does not implement swing yet. And why is it used in lwjgl? I thought lwjgl does not have any references to awt/swing already, but... I tried to get rid of that class, but it is used in others... etc... IMHO will get broken that way :-)
So am I using the wrong verion of lwjgl? What can be done? I'm clearly able to get stuff from CVS and modify java sources. Just give me some directions...

Thanx,
Michael.
Title: GCJ again
Post by: elias on November 20, 2005, 10:15:11
Which version of gcj are you using? I do:


gcj -Ilibs/jinput.jar -c libs/lwjgl.jar


without getting any errors. My gcj version is:


gcc version 4.0.2 20050901 (prerelease) (SUSE Linux)


from SUSE 10.0.

- elias
Title: GCJ again
Post by: teddybear on November 20, 2005, 11:18:55
I'm using gcc (gcj) v 3.4 for MinGW obtained from:
http://www.thisiscool.com/gcc_mingw.htm
v 4.0.2 is available but is limited (has broken dynamic builds, unusable).

This comes bundled with a few variations of libgcj:
original (no AWT/SWING at all)
gui (modified to include some AWT/SWING support).

using those two differ in error messages :-)
Do you think I should obtain a newer version of libgcj? Well, if you say you compile without errors... it is likely to be so.

By the way, I used proguard on my sample and libraries and it successfully trashed out all the awt/swing stuff... Currently I'm choking on other errors, related to my code... havent launched yet.

Thanx for the tip!
Title: GCJ again
Post by: elias on November 20, 2005, 11:32:53
Ah, you're running on windows... I'm a bit surprised that the 4.x gcj version is not yet available on mingw. If you want to work around the swing problem, you could try commenting out the swing code in alert(), instead of removing the class altogether.

- elias
Title: GCJ again
Post by: teddybear on November 20, 2005, 11:37:01
Just now tried out libgcj v 4.0.2. The error picture has changed:

org/lwjgl/opengl/AWTGLCanvas.java:0: error: cannot find file for class java.awt.event.HierarchyListener
org/lwjgl/opengl/AWTGLCanvas.java: In class `org.lwjgl.opengl.AWTGLCanvas':
org/lwjgl/opengl/AWTGLCanvas.java: In constructor `(java.awt.GraphicsDevice,org.lwjgl.opengl.PixelFormat,org.lwjgl.opengl.Drawab
le)':
org/lwjgl/opengl/AWTGLCanvas.java:60: error: cannot find file for class java.awt.event.HierarchyListener
org/lwjgl/opengl/AWTGLCanvas.java:60: confused by earlier errors, bailing out

It seems like I have seen this somewhere before :-) ? havent you fixed it already? I'm compiling v 0.98.
Title: GCJ again
Post by: elias on November 20, 2005, 11:47:30
Same version but different error message? No, I don't recall anything about that particular error message. I'm building from CVS, but I don't think that makes a difference in this case.

- elias
Title: GCJ again
Post by: teddybear on November 20, 2005, 12:07:07
Taht should not matter since we use the same sources. Could you please go to your GCJ and see if jour libgcj has the class java.awt.event.HierarchyListener, please? Mine has NOT... Im' only lucky to have proguard optimize lwjgl + my sample ;-) it seems to get rid of that AWT dependency...
Title: GCJ again
Post by: elias on November 20, 2005, 14:51:46
I do, in a "/usr/share/java/libgcj-4.0.2.jar".

- elias
Title: GCJ again
Post by: teddybear on November 20, 2005, 19:15:09
!!! How could that be??? a libgcj-4.0.2.jar (9141650 bytes) does NOT have that awt class (actually, it has 2 classes in awt package... and no swing) It seems like swingWT is buildt into your lib? No wonder I have trouble compiling...
Title: GCJ again
Post by: teddybear on November 21, 2005, 12:23:02
Reding this once again :
http://www.thisiscool.com/gcc_mingw.htm
I found the problem: the bundled libgcj is surgically modified, in particular, GNU awt/swing is replaced with swingWT! That is probably why there is difference between this minGW gcc/gcj bundle and original under *nux.

Hope this helps somebody. Also java@gcc.gnu.org mailing list is very usefull for the purpose of compiling anything to native.

... just wait for a new release from thisiscool or build or yourself a cross-compiler :-) ...gonna try the second...
Title: GCJ again
Post by: kappa on November 21, 2005, 15:33:04
ah it works with gcc 4.0, is there much of a performance improvement with gcc as compared with just normal java?

what sort of sizes exe can you get?
do you still need the jre?
does swings now work?
Title: GCJ again
Post by: teddybear on November 21, 2005, 15:47:29
jre is not needed (why hten bother with native???)
speed is hopefully not worse (probably not better)
memory consumption is lower
exe size id HUGE with debug info, awsome stripped and acceptable compressed :-)

currently I'm in process of obtaining a working build of gcj 4.x ... I will probably put a FAQ or a tutorial as soon as I get it working... damn, building a cross-compiler (or a crossed-native) is kinda difficult... ;-(
Title: GCJ again
Post by: kappa on November 21, 2005, 22:50:58
ah thx for the reply, i look forward to your tutorial/faq :)
Title: GCJ again
Post by: teddybear on December 02, 2005, 19:01:37
Hello!

All those time I was investigating this matter and... I have made progress!
Well not  everything is smooth, but I WAS able to compile relatively complex prototype of my game: lwjgl+swt+swtforms+bindings+XML+...

Don't ask me about details related to gcc/gcj - I'm not a guru, not a bit. Here is the recepy:

1) get gcj v 4.0.2 from http://www.thisiscool.com/gcc_mingw.htm (build by Mohan Embar [many thanks!!!] )
2) read readme. I mean it!
3) make it link staticaly with original libgcj
4) patch your lwjgl.jar with fix described in (at the end): http://lwjgl.org/forum/viewtopic.php?t=1165&postdays=0&postorder=asc&highlight=gcj&start=30
5) repack your application to a single jar file (includin ALL third-party libs you need, including lwjgl.jar etc.)
6) compile your big-jar with:
gcj -fjni -findirect-dispatch yourjar.jar -o your.exe
or similar. The most important are -fjni -findirect-dispatch
7) compillation/linking will go without errors, but (!) it doesn't matter it will not fail... Try running. Fail. Study the log. If it lacks some class, go to cgj_dir\shared\->->->\libgcj-4.0.2.jar, grab the whole bunch of related classes from there and pack in your big-jar. Recompile, rerun.

Do not try any version of gcj below 4.x - bugs in jni. Version 4.x for mingw still BUGGY and my solution appeared as a result of working them aroud. Currently crashes on regular expressions (and some string operations, which seem to be implemented using regexps).

8) finally strip -s your.exe
9) upx -9 your.exe

Enjoy!

Michael.
P.S. Comments are welcome!!!!!!!