arton / rjb

Ruby Java Bridge
https://www.artonx.org/collabo/backyard/?RubyJavaBridge
GNU Lesser General Public License v2.1
117 stars 34 forks source link

rjb doesn't compile on Cygwin #29

Closed thorstenkampe closed 10 years ago

thorstenkampe commented 10 years ago

This seems to be the same issue as in issue #7 ("rjb fails to compile on windows"). This is on Cygwin64 with a 64-bit JDK 8. Same error on Cygwin32 with a 32-bit JDK.

Putting typedef long long __int64; (from jniwrap.h) above typedef __int64 jlong; in jni_md.h fixes the error.

Thorsten

$ gem install --user-install rjb
WARNING:  You don't have /home/thorsten/.gem/ruby/1.9.1/bin in your PATH,
          gem executables will not run.
Building native extensions.  This could take a while...
ERROR:  Error installing rjb:
        ERROR: Failed to build gem native extension.

        /usr/bin/ruby.exe extconf.rb
checking for jni.h... yes
checking for locale_charset() in iconv.h... no
checking for nl_langinfo() in langinfo.h... yes
checking for setlocale() in locale.h... yes
checking for getenv()... yes
creating extconf.h
creating Makefile

make
make: Warning: File 'Makefile' has modification time 1,5 s in the future
gcc -I. -I/usr/include/ruby-1.9.1/x86_64-cygwin -I/usr/include/ruby-1.9.1/ruby/backward -I/usr/include/ruby-1.9.1 -I. -I"/cygdrive/c/Program Files/Java/jdk1.8.0_05/include" -I"/cygdrive/c/Program Files/Java/jdk1.8.0_05/include/win32" -DRUBY_EXTCONF_H=\"extconf.h\"    -ggdb -O2 -pipe -Wimplicit-function-declaration   -fno-strict-aliasing  -I"/cygdrive/c/Program Files/Java/jdk1.8.0_05/include" -I"/cygdrive/c/Program Files/Java/jdk1.8.0_05/include/win32"  -o load.o -c load.c
In file included from /cygdrive/c/Program Files/Java/jdk1.8.0_05/include/jni.h:45:0,
                 from jniwrap.h:29,
                 from load.c:31:
/cygdrive/c/Program Files/Java/jdk1.8.0_05/include/win32/jni_md.h:34:1: Fehler: unbekannter Typname: »__int64«
 typedef __int64 jlong;
 ^
Makefile:206: recipe for target 'load.o' failed
make: *** [load.o] Error 1

Gem files will remain installed in /home/thorsten/.gem/ruby/1.9.1/gems/rjb-1.4.9 for inspection.
Results logged to /home/thorsten/.gem/ruby/1.9.1/gems/rjb-1.4.9/ext/gem_make.out
thorstenkampe commented 10 years ago

Correction: compiling does work in Cygwin32 but it gives directly this error on invocation of the gem:

Error occurred during initialization of VM
java/lang/NoClassDefFoundError: java/lang/Object
arton commented 10 years ago

Hi Thorsten

Do you know CYGWIN specific directive ? It can be compiled fine on both Visual C and mingw gcc. And I don't use Cygwin and have no knowledge about Cygwin's compiler. That means, I can't put long long stuff because if I put it on my code, Visual C can't compile it. It's more problematic for me and Visual C users. The only resolution is you may write the code and make pull request that makes:

if defined( CYWGIN specific symbole I have no knowledge and don't want investigate it)

typedef long long __int64;

endif

Regards.

thorstenkampe commented 10 years ago

There are actually two issues:

#if defined(__GNUC__) && (defined(__CYGWIN32__) || defined(__MINGW32__))
 #if !defined(__int64)
  typedef long long __int64;
 #endif
#endif

https://cygwin.com/cygwin-ug-net/programming.html#gcc-64

While the Mingw and Microsoft compilers use the LLP64 data model, Cygwin compilers use the LP64 data model, just like Linux. This affects the size of the type long. In the LLP64 model preferred by Microsoft, sizeof(long) is 4. This applies for the related Win32 types like LONG, ULONG, DWORD, etc., too.

But I would be fine using Mingw GCC (instead of Cygwin's gcc) if you have instructions how to do that.

arton commented 10 years ago

I believe that using Mingw gcc in most popular way is: http://rubyinstaller.org/ It installs and prepares environment for ruby, mingw and some required libraries. And you can install gems naturally. Best regards.