Compiling libgjc under cygwin

Julian Hall jules@acris.co.uk
Tue Jul 3 11:34:00 GMT 2001


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-cygwin/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