Compiling libgjc under cygwin

Kevin Powell kpowell@enuvis.com
Tue Jul 3 12:55:00 GMT 2001


Julian -- 

My understanding is that the win32 threading does not work at this
point.  I also tried to compile the 3.0 libgcj distribution on Cygwin,
but had very little success.  Eventually, I switched over to using the
CVS version from the trunk.

I was able to get some of the way through the bootstrap process by using
--enable-threads=posix, but
I had to do some further patching:
1) I found a hack for jcf-parse.c that got rid of the case-sensitivity
thing (can't remember who posted it).
2) Had to change a strncmp to strncasecmp in parse.c (for the
case-sensitivity thing, again)
3) had to hack winnt.c :
http://gcc.gnu.org/ml/gcc-patches/2001-06/msg01803.html
4) had to tweak the timezone stuff -- this is mostly documented in the
list archives, but I had to read time.h to get everything right.
5) various Makefile hacking to get rid of -lpthread
6) There was an annoying complaint from the parser about reading class
files twice, which I got past by commenting out the error code. (which
probably would have broken things later)	  

However, I never did get things to work.  The thing that I couldn't get
past was gcj complaining about multiple definitions of a function in the
Class class. I found a discussion of the problem on the list, but the
posted solution never worked for me.  

>From searching through the lists, I've concluded that there's still a
bunch of work to be done before gcj works on Cygwin.

Kevin Powell

-----Original Message-----
From: Julian Hall [ mailto:jules@acris.co.uk ]
Sent: Tuesday, July 03, 2001 11:40 AM
To: cygwin@cygwin.com; java@gcc.gnu.org
Subject: Compiling libgjc under cygwin


Hi; I know that for the moment this is unsupported but I'm trying to get
libgjc from the gcc-3.0 distribution to compile in a cygwin environment.

I've figured out the following:

- I've looked at win32-threads.cc and the threads porting documentation,
and guess from the looks of it that it should work OK as distributed (?)

- I modified configure so that it would recognise gcc's win32 thread
model and choose win32-threads.cc
- The resulting makefile had java.awt packages that failed to compile,
so I simply removed all of the awt and related sources.  I think the
compilation errors here were due to the case-insensitivity of the file
system: they were effectively errors about duplicate class definitions
in (eg) image.java and Image.java.
- java/util/natGregorianCalendar.cc wasn't compiling correctly; I had to
forcibly undefine HAVE_TIMEZONE to persuade it to work, as the
definition of 'timezone' it used was incompatible with the cygwin
definition.
- Fastjar required patching in order to function correctly; the patch I
applied is attached, and simply causes files to be opened with the
O_BINARY flag if it is defined.

However, I am still faced with compile errors when it comes to linking
the utilitty programs that are part of the library; the errors
specifically are:

./.libs/libgcj.a(natClass.o): In function `ZN4java4lang5Class4sizeEv':
/usr/local/src/gcc-cygwin-w32threads/i686-pc-cygwin/libjava/../../../gcc
-3.0/libjava/java/lang/Class.h(.text$_ZN4java4lang5ClassC1Ev+0x0):
multiple definition of `java::lang::Class::Class()'
./.libs/libgcj.a(Class.o):/usr/local/src/gcc-cygwin-w32threads/i686-pc-c
ygwin/libjava/../../../gcc-3.0/libjava/java/lang/Class.java:168:
first defined here
./.libs/libgcj.a(win32-threads.o): In function
`Z18_Jv_ThreadInitDataPN4java4lang6ThreadE':
/usr/local/src/gcc-cygwin-w32threads/i686-pc-cygwin/libjava/../../../gcc
-3.0/libjava/win32-threads.cc:129:
undefined reference to `operator new(unsigned)'
./.libs/libgcj.a(win32-threads.o): In function
`Z21_Jv_ThreadDestroyDataP12_Jv_Thread_t':
/usr/local/src/gcc-cygwin-w32threads/i686-pc-cygwin/libjava/../../../gcc
-3.0/libjava/win32-threads.cc:138:
undefined reference to `operator delete(void*)'
./.libs/libgcj.a(natFirstThread.o): In function
`ZN3gnu3gcj7runtime11FirstThread3runEv':
/usr/local/src/gcc-cygwin-w32threads/i686-pc-cygwin/libjava/../../../gcc
-3.0/libjava/gnu/gcj/runtime/natFirstThread.cc:60:
undefined reference to `JNI_OnLoad'
/usr/local/src/gcc-cygwin-w32threads/i686-pc-cygwin/libjava/../../../gcc
-3.0/libjava/gnu/gcj/runtime/natFirstThread.cc:68:
undefined reference to `JNI_OnLoad'
./.libs/libgcj.a(SimpleTimeZone.o)(.data+0x0):SimpleTimeZone.java:
undefined reference to `Jv_byteVTable'
./.libs/libgcj.a(ZipEntry.o): In function
`ZN4java4util3zip8ZipEntryC1EPNS_4lang6StringE':
/usr/local/src/gcc-cygwin-w32threads/i686-pc-cygwin/libjava/../../../gcc
-3.0/libjava/java/util/zip/ZipEntry.java:65:
undefined reference to `Jv_shortVTable'
./.libs/libgcj.a(GregorianCalendar.o)(.data+0x0):GregorianCalendar.java:
undefined reference to `Jv_intVTable'
./.libs/libgcj.a(GregorianCalendar.o): In function
`ZN4java4util17GregorianCalendarC1EPNS0_8TimeZoneE':
/usr/local/src/gcc-cygwin-w32threads/i686-pc-cygwin/libjava/../../../gcc
-3.0/libjava/java/util/GregorianCalendar.java:100:
undefined reference to `Jv_intVTable'
./.libs/libgcj.a(GregorianCalendar.o): In function
'ZN4java4util17GregorianCalendarC1EPNS0_8TimeZoneEPNS0_6LocaleE':
/usr/local/src/gcc-cygwin-w32threads/i686-pc-cygwin/libjava/../../../gcc
-3.0/libjava/java/util/GregorianCalendar.java:113:
undefined reference to `Jv_intVTable'
./.libs/libgcj.a(InetAddress.o): In function
`ZN4java3net11InetAddressC1EP6JArrayIcEPNS_4lang6StringE':
/usr/local/src/gcc-cygwin-w32threads/i686-pc-cygwin/libjava/../../../gcc
-3.0/libjava/java/net/InetAddress.java:74:
undefined reference to `Jv_byteVTable'
./.libs/libgcj.a(natInflater.o): In function
`ZN4java4util3zip8Inflater3endEv':
/usr/local/src/gcc-cygwin-w32threads/i686-pc-cygwin/libjava/../../../gcc
-3.0/libjava/java/util/zip/natInflater.cc:53:
undefined reference to `inflateEnd'
./.libs/libgcj.a(natInflater.o): In function
`ZN4java4util3zip8Inflater7inflateEP6JArrayIcEii':
/usr/local/src/gcc-cygwin-w32threads/i686-pc-cygwin/libjava/../../../gcc
-3.0/libjava/java/util/zip/natInflater.cc:107:
undefined reference to `inflate'
./.libs/libgcj.a(natInflater.o): In function
`ZN4java4util3zip8Inflater5resetEv':
/usr/local/src/gcc-cygwin-w32threads/i686-pc-cygwin/libjava/../../../gcc
-3.0/libjava/java/util/zip/natInflater.cc:151:
undefined reference to `inflateReset'
./.libs/libgcj.a(natInflater.o): In function
`ZN4java4util3zip8Inflater13setDictionaryEP6JArrayIcEii':
/usr/local/src/gcc-cygwin-w32threads/i686-pc-cygwin/libjava/../../../gcc
-3.0/libjava/gcj/array.h:46:
undefined reference to `inflateSetDictionary'
./.libs/libgcj.a(natInflater.o): In function
`ZN4java4util3zip8Inflater4initEb':
/usr/local/src/gcc-cygwin-w32threads/i686-pc-cygwin/libjava/../../../gcc
-3.0/libjava/java/util/zip/natInflater.cc:200:
undefined reference to `inflateInit2_'
collect2: ld returned 1 exit status

I've also tried configuring the entire system with
--enable-threads=posix, but gcc is unable to compile correctly if I do
this.

Any ideas what needs to be done to solve these problems?

Oh, and thanks for producing such great products; I've been using cygwin
under windows for quite a while and have just started with gcj under
linux and like the results so far! Great work.

Jules



More information about the Java mailing list