arton/rjb — Issue #7: rjb fails to compile on windows
Author: Noymn
Created: 2012-01-27 17:51:07+00:00
State: open

Rjb gem fails to compile on windows, either with Ruby 1.8.7 or 1.9.2. This is because the way to define long integers is not compatible with the gcc compiler provided by mingw.

The file that fails is `ext/jniwrap.h` and the line is the following one:

```ruby
typedef long long __int64;
```
Replacing it with the following definition works:

```ruby
typedef long long long64;
```

Sample of the error log:

Building native extensions. This could take a while...
ERROR: Error installing rjb:
ERROR: Failed to build gem native extension.
C:/Ruby192/bin/ruby.exe extconf.rb

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

make
C:/Ruby192/bin/ruby -e "puts 'EXPORTS', 'Init_rjbcore'" > rjbcore-i386-mingw32.def
gcc -I. -IC:/Ruby192/include/ruby-1.9.1/i386-mingw32 -I/C/Ruby192/include/ruby-1.9.1/ruby/backward -I/C/Ruby192/include/ruby-1.9.1 -I. -I"C:\Program Files\Java\jdk1.6.0_25\include" -I"C:\Program Files\Java\jdk1.6.0_25\include\win32" -DRUBY_EXTCONF_H=
\"extconf.h\" -O3 -g -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -I"C:\Program Files\Java\jdk1.6.0_25\include" -I"C:\Program Files\Java\jdk1.6.0_25\include\win32" -
o load.o -c load.c
In file included from load.c:31:0:
jniwrap.h:24:19: error: 'long long long' is too long for GCC
jniwrap.h:24:19: error: 'long long long' is too long for GCC
jniwrap.h:24:1: warning: useless type name in empty declaration
load.c: In function 'load_bridge':
load.c:262:21: warning: assignment discards qualifiers from pointer target type
load.c:263:26: warning: assignment discards qualifiers from pointer target type
load.c: In function 'rjb_create_jvm':
load.c:283:7: warning: initialization discards qualifiers from pointer target type
load.c:366:19: warning: comparison between signed and unsigned integer expressions
load.c:370:14: warning: comparison between signed and unsigned integer expressions
make: *** [load.o] Error 1

Gem files will remain installed in C:/Ruby192/lib/ruby/gems/1.9.1/gems/rjb-1.3.3 for inspection.
Results logged to C:/Ruby192/lib/ruby/gems/1.9.1/gems/rjb-1.3.3/ext/gem_make.out