This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

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

--- jartool.c.orig	Sat Jun 30 12:25:47 2001
+++ jartool.c	Sat Jun 30 13:33:12 2001
@@ -206,11 +206,13 @@
 
 #endif
 
 static char version_string[] = VERSION;
 
+#ifndef errno /* errno may be a macro defined to call a function for threads */
 extern int errno;
+#endif
 
 void usage(const char*);
 void add_entry(struct zipentry *);
 void init_headers(void);
 
@@ -363,21 +365,25 @@
   }
 
   /* create the jarfile */
   if(action == ACTION_CREATE){
     if(file){
+#ifdef O_BINARY
+      jarfd = open(jarfile, O_CREAT | O_BINARY | O_RDWR, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+#else
       jarfd = creat(jarfile, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
-      
+#endif
+	
       if(jarfd < 0){
         fprintf(stderr, "Error opening %s for writing!\n", jarfile);
         perror(jarfile);
         exit(1);
       }
       
       /* We assume that the file is seekable */
       seekable = TRUE;
       
     } else {
       
       jarfd = STDOUT_FILENO;  /* jarfd is stdout otherwise */
       
       /* standard out is not seekable */
@@ -388,11 +394,15 @@
       verbose = FALSE;
     }
   } else if(action == ACTION_LIST || action == ACTION_EXTRACT){
 
     if(file){
+#ifdef O_BINARY
+      jarfd = open(jarfile, O_RDONLY | O_BINARY);
+#else
       jarfd = open(jarfile, O_RDONLY);
+#endif
 
       if(jarfd < 0){
         fprintf(stderr, "Error opening %s for reading!\n", jarfile);
         perror(jarfile);
         exit(1);
@@ -410,11 +420,15 @@
   if(action == ACTION_CREATE || action == ACTION_UPDATE){
     const char *arg;
     init_headers();
 
    if((action == ACTION_UPDATE) && file) {
+#ifdef O_BINARY
+      if((jarfd = open(jarfile, O_RDWR | O_BINARY)) < 0) {
+#else
       if((jarfd = open(jarfile, O_RDWR)) < 0) {
+#endif
 	fprintf(stderr, "Error opening %s for reading!\n", jarfile);
         perror(jarfile);
         exit(1);
       }
     }
@@ -867,11 +881,15 @@
     closedir(dir);
       
   } else if(S_ISREG(statbuf.st_mode)){
     int add_fd;
 
+#ifdef O_BINARY
+    add_fd = open(file, O_RDONLY | O_BINARY);
+#else
     add_fd = open(file, O_RDONLY);
+#endif
     if(add_fd < 0){
       fprintf(stderr, "Error opening %s.\n", file);
       return 0;
     }
     

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]