gcc 3.3.1-3, loading .la files from gcj-compiled apps

Marcus G. Daniels mgd@santafe.edu
Sun Nov 2 19:20:00 GMT 2003


Would it be possible to add a -D_WIN32 to the libjava/libltdl Makefile 
for Cygwin?  Then the LoadLibrary support will get compiled-in, and 
dynamic libraries can be loaded into GCJ apps.  If this is done, then a 
__CYGWIN__ conditional is needed in ltdl.c in order to first normalize 
the path for Windows, e.g. here's how I hacked it in my copy (not 
intended as a patch, just for illustration).   Also, I found I had to 
duplicate the stack copy of `buf' in java::lang::Runtime:_load in order 
to avoid it getting wiped out from the the exception getting caught.  
Please see the second illustrative patch.  With these two changes, I can 
use LoadLibrary in GCJ-compiled apps with libtool dynamic libraries in 
the same way that Sun JDK can load ordinary DLLs.

*** ltdl.c-orig    Sun Nov  2 11:12:58 2003
--- ltdl.c    Sun Nov  2 11:13:23 2003
***************
*** 479,486 ****
          strcpy(searchname, filename);
          strcat(searchname, ".");
      }
!
!     module = LoadLibrary(searchname);
      lt_dlfree(searchname);
     
      /* libltdl expects this function to fail if it is unable
--- 479,490 ----
          strcpy(searchname, filename);
          strcat(searchname, ".");
      }
!         {
!            char buf[1024];
!           
!            cygwin_conv_to_win32_path (searchname, buf);
!        module = LoadLibrary(buf);
!         }
      lt_dlfree(searchname);
     
      /* libltdl expects this function to fail if it is unable


*** natRuntime.cc-orig    Sun Nov  2 08:58:56 2003
--- natRuntime.cc    Sun Nov  2 11:59:29 2003
***************
*** 174,180 ****
    jsize total = JvGetStringUTFRegion (path, 0, path->length(), 
&buf[offset]);
    buf[offset + total] = '\0';
 
!   char *lib_name = buf;
 
    if (do_search)
      {
--- 174,180 ----
    jsize total = JvGetStringUTFRegion (path, 0, path->length(), 
&buf[offset]);
    buf[offset + total] = '\0';
 
!   char *lib_name = strdup (buf);
 
    if (do_search)
      {



More information about the Java mailing list