.java to .exe on win32 with Cygwin
# 2003-09-26 08:39:47 -0400 | Java | 13 Comments
I updated my Cygiwn installation last
night and noticed that I now have gcj, the “ahead-of-time compiler for the Java language”. Unable to resist, I coded up a “hello world” program.
$ ls
Test.java
$ uname -a
CYGWIN_NT-5.0 tiny 1.5.5(0.94/3/2) 2003-09-20 16:31 i686 unknown unknown Cygwin
$ cat Test.java
public class Test {
public static void main(String[] args) {
System.out.println(”Hello, world!”);
}
}
$ gcj –main=Test -o Test Test.java
$ ls
Test.exe Test.java
$ ./Test
Hello, world!
Cool. Also, I belive gcj is availiable in the
MinGW 3.3.1 release candidate.
MingGW allows you to use the gcc tools on win32 “without cygwin.dll”.
Maybe someone needs to compile up a native version of Eclipse on win32. ;-)
See http://www.thisiscool.com/gcc_mingw.htm.
Regards,
Ashwin.
How big is the .exe?
Natively Compiled Eclipse for Linux:
http://sources.redhat.com/eclipse/
The .exe is about 2.5 MB. I assume that represents alot of "overhead".
$ ls -l Test.exe
-rwxrwxrwx 1 matt None 2723868 Sep 26 08:32 Test.exe
makes me want to install cygwin again now. used to use it ages ago but had moral issues with trying to make my non-unix based OS look like unix.
but i’m willing to give it a shot again. i hate windows enough to make it happen.
% uname -a
CYGWIN_NT-5.0 SKANGA-W2K3 1.5.5(0.94/3/2) 2003-09-20 16:31 i686 unknown unknown Cygwin
% cat Test.java
public class Test {
public static void main(String[] args) {
System.out.println("Hello, world!");
}
}
% gcj –main=Test -o Test Test.java
/usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/../../../../i686-pc-cygwin/bin/ld: cannot
find -liconv
collect2: ld returned 1 exit status
Maybe I need to install something else? Any ideas
You can install libiconv via the Cygwin setup.exe
le tme test it
Let me test it
$ gcj –main=Test -o Test Test.java
/cygdrive/c/DOCUME~1/DANOUNOU/LOCALS~1/Temp/ccg9iXyc.o(.text+0×39): In function
main':Test::class$’/cygdrive/c/DOCUME~1/DANOUNOU/LOCALS~1/Temp/ccLDUFzr.i: undefined reference to
collect2: ld returned 1 exit status
worked for me:
$ gcj –main=Test -o Test Test.java
$ ./Test.exe
Hello, world!
$ gcj –version
gcj (GCC) 3.3.1 (cygming special)
Can you compile GUI applications?
Ok, I insalled libiconv and can not build and run Test.java within ming32. Is there anyway to staticly link in libiconv so I run the executable from dos ?