Forum: Ruby Making/Compiling Gems on Windows with MinGW

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Db2175eb86669d396b8596d11478f5ef?d=identicon&s=25 Cayce Balara (yardboy)
on 2008-10-03 22:17
Whenever I try to install a gem that doesn't have a precompiled binary
available I get an error like this:

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --srcdir=.
        --curdir
        --ruby=c:/server/ruby/bin/ruby

This is coming out of the call to the extconf.rb for the gem. If I try
to execute that directly, the options don't seem to change. For
instance:

ruby ext/extconf.rb --without-opt-include=c:/server/mingw/include

I run that command and the error report shows the same, no change to the
reported --without-opt-include configuration option.

So it doesn't appear as if I'm calling it correctly since the custom
configuration option is not making it through.

More importantly, where are the default configuration options stored,
and how can I change them to point to the MinGW files for make-ing and
compiling?

thanks.
Db2175eb86669d396b8596d11478f5ef?d=identicon&s=25 Cayce Balara (yardboy)
on 2008-10-03 22:20
Sorry - Windows XP, SP2, I've installed MinGW.
E7cff3cfd41c495e1012227d7dc24202?d=identicon&s=25 Luis Lavena (luislavena)
on 2008-10-04 17:26
(Received via mailing list)
On Oct 3, 6:15 pm, Cayce Balara <ho...@balara.com> wrote:
>         --with-make-prog
> I run that command and the error report shows the same, no change to the
> reported --without-opt-include configuration option.
>
> So it doesn't appear as if I'm calling it correctly since the custom
> configuration option is not making it through.
>
> More importantly, where are the default configuration options stored,
> and how can I change them to point to the MinGW files for make-ing and
> compiling?
>
> thanks.

What gem are you trying to compile?

Also, if you have gcc.exe and make.exe in your PATH, there will be no
issues with it.

Keep in mind that the ruby version you're using *must* be the one
build with MinGW, and will not work with the one build with VC6. To
spot this difference run "ruby -v" and see the platform information.

mswin32: VC6 build
mingw32: MinGW (GCC) build

using --without-* you're excluding the 'include' files, the opposite
that you want to achieve :-)

Use --with-opt-include=C:/server/mingw/include

HTH,
Db2175eb86669d396b8596d11478f5ef?d=identicon&s=25 Cayce Balara (yardboy)
on 2008-10-05 17:37
>
> What gem are you trying to compile?
>

eventmachine is the one I'm currently having problems with but there are
others, like hpricot, that I just have older versions of that are
precompiled instead of the most current build.

> Also, if you have gcc.exe and make.exe in your PATH, there will be no
> issues with it.

the error messages point to a misshing header file - specifically
windows.h - not that the gcc/make executables can't be found. I do have
those in the PATH.

>
> Keep in mind that the ruby version you're using *must* be the one
> build with MinGW, and will not work with the one build with VC6. To
> spot this difference run "ruby -v" and see the platform information.
>
> mswin32: VC6 build
> mingw32: MinGW (GCC) build
>

I appreciate that - I was not aware of the fact that they had to
'match'. I've definitely got the VC6 build, so that's most likely my
problem.

> using --without-* you're excluding the 'include' files, the opposite
> that you want to achieve :-)
>
> Use --with-opt-include=C:/server/mingw/include

I've tried all of the options that appeared to be useful - no luck. I
think it's the issue above.

>
> HTH,

Thanks so much for the reply and the assistance!

c.
D0338c0de4cb3c5c17300396159933d1?d=identicon&s=25 Axel Etzold (Guest)
on 2008-10-05 21:15
(Received via mailing list)
-------- Original-Nachricht --------
> Datum: Mon, 6 Oct 2008 00:36:16 +0900
> Von: Cayce Balara <house@balara.com>
> An: ruby-talk@ruby-lang.org
> Betreff: Re: Making/Compiling Gems on Windows with MinGW

>
> > mingw32: MinGW (GCC) build
>
> Posted via http://www.ruby-forum.com/.
Dear Cayce,

some time ago, there was a gems compilation on Vista discussion on this
list:

http://www.ruby-forum.com/topic/162379

I tried to compile some gems in Windows Vista, but could not get VC6 to
install
at all on Vista...
As the problem to be solved was to install hpricot, there's a
precompiled way to do
this (see my post on 30.08.2008 15:59 on the thread above).

I did some research to find out that IIRC  _why, the author of hpricot,
had actually cross-compiled the Windows gem on some *nix version.

For the eventmachine gem, there are also binary versions on Rubyforge.

Please let us know if you do get VC6 to compile on Windows Vista (and
how).

Best regards,

Axel
Db2175eb86669d396b8596d11478f5ef?d=identicon&s=25 Cayce Balara (yardboy)
on 2008-10-06 02:09
Appreciate the additional info. However, I'm on Windows XP and will
likely never make the move to Vista.

Just didn't want anyone holding their breath on that. :)
Efdb04c4dac4a962d86e25361f8fd450?d=identicon&s=25 James M. Lawrence (quix)
on 2008-10-06 02:43
>> Keep in mind that the ruby version you're using *must* be the one
>> build with MinGW, and will not work with the one build with VC6. To
>> spot this difference run "ruby -v" and see the platform information.
>>
>> mswin32: VC6 build
>> mingw32: MinGW (GCC) build
>>
>
> I appreciate that - I was not aware of the fact that they had to
> 'match'. I've definitely got the VC6 build, so that's most likely my
> problem.

Just to clarify, mingw32 is C-wise ABI compatible with VC6.  The
difference is in the runtime library linked into the final ruby
executable.

For example you can use mingw to compile extensions for the one-click
installer, even though that ruby is linked to the VC6 msvcrt.  Since an
extension is not a binary .exe, the mingw runtime isn't needed and isn't
linked in.

Note C++ is always ABI-incompatible across compilers, as name mangling
and runtime implementations (exceptions, rtti, etc) are different (even
purposefully different to avoid possible mix-ups).
Db2175eb86669d396b8596d11478f5ef?d=identicon&s=25 Cayce Balara (yardboy)
on 2008-10-07 19:57
Okay - I have gotten rid of MinGW and installed VC6. At least now I am
getting something, but still receiving errors. Would anyone who has
responded be able to point me in the right direction for a resolution to
the error below?

thanks.
c.




c:/server/ruby/bin/ruby.exe extconf.rb install eventmachine
checking for windows.h... yes
checking for winsock.h... yes
checking for main() in kernel32.lib... yes
checking for main() in rpcrt4.lib... yes
checking for main() in gdi32.lib... yes
checking for main() in ssleay32.lib... no
creating Makefile

nmake

Microsoft (R) Program Maintenance Utility   Version 6.00.8168.0
Copyright (C) Microsoft Corp 1988-1998. All rights reserved.

  cl -I. -I. -Ic:/server/ruby/lib/ruby/1.8/i386-mswin32 -I. -MD -Zi
-O2b2xg- -G6 -DHAVE_WINDOWS_H -DHAVE_WINSOCK_H  -D OS_WIN32 -D
BUILD_FOR_RUBY -EHs -GR -D WITHOUT_SSL -c -Tpbinder.cpp
Microsoft (R) 32-bit C/C++ Standard Compiler Version 12.00.8168 for
80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

Command line warning D4002 : ignoring unknown option '-Ob2'
Command line warning D4002 : ignoring unknown option '-Og-'
binder.cpp
  cl -I. -I. -Ic:/server/ruby/lib/ruby/1.8/i386-mswin32 -I. -MD -Zi
-O2b2xg- -G6 -DHAVE_WINDOWS_H -DHAVE_WINSOCK_H  -D OS_WIN32 -D
BUILD_FOR_RUBY -EHs -GR -D WITHOUT_SSL -c -Tpcmain.cpp
Microsoft (R) 32-bit C/C++ Standard Compiler Version 12.00.8168 for
80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

Command line warning D4002 : ignoring unknown option '-Ob2'
Command line warning D4002 : ignoring unknown option '-Og-'
cmain.cpp
  cl -I. -I. -Ic:/server/ruby/lib/ruby/1.8/i386-mswin32 -I. -MD -Zi
-O2b2xg- -G6 -DHAVE_WINDOWS_H -DHAVE_WINSOCK_H  -D OS_WIN32 -D
BUILD_FOR_RUBY -EHs -GR -D WITHOUT_SSL -c -Tpcplusplus.cpp
Microsoft (R) 32-bit C/C++ Standard Compiler Version 12.00.8168 for
80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

Command line warning D4002 : ignoring unknown option '-Ob2'
Command line warning D4002 : ignoring unknown option '-Og-'
cplusplus.cpp
  cl -I. -I. -Ic:/server/ruby/lib/ruby/1.8/i386-mswin32 -I. -MD -Zi
-O2b2xg- -G6 -DHAVE_WINDOWS_H -DHAVE_WINSOCK_H  -D OS_WIN32 -D
BUILD_FOR_RUBY -EHs -GR -D WITHOUT_SSL -c -Tped.cpp
Microsoft (R) 32-bit C/C++ Standard Compiler Version 12.00.8168 for
80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

Command line warning D4002 : ignoring unknown option '-Ob2'
Command line warning D4002 : ignoring unknown option '-Og-'
ed.cpp
  cl -I. -I. -Ic:/server/ruby/lib/ruby/1.8/i386-mswin32 -I. -MD -Zi
-O2b2xg- -G6 -DHAVE_WINDOWS_H -DHAVE_WINSOCK_H  -D OS_WIN32 -D
BUILD_FOR_RUBY -EHs -GR -D WITHOUT_SSL -c -Tpem.cpp
Microsoft (R) 32-bit C/C++ Standard Compiler Version 12.00.8168 for
80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

Command line warning D4002 : ignoring unknown option '-Ob2'
Command line warning D4002 : ignoring unknown option '-Og-'
em.cpp
em.cpp(1193) : error C2374: 'i' : redefinition; multiple initialization
        em.cpp(1186) : see declaration of 'i'
NMAKE : fatal error U1077: 'cl' : return code '0x2'
Stop.
F1d6cc2b735bfd82c8773172da2aeab9?d=identicon&s=25 Nobuyoshi Nakada (nobu)
on 2008-10-08 05:42
(Received via mailing list)
Hi,

At Wed, 8 Oct 2008 02:55:48 +0900,
Cayce Balara wrote in [ruby-talk:317108]:
> em.cpp(1193) : error C2374: 'i' : redefinition; multiple initialization
>         em.cpp(1186) : see declaration of 'i'

It's a famous pitfall of VC6.

A workaround is:

#if defined __cplusplus && defined _MSC_VER && _MSC_VER == 1200
#define for if (1) for
#endif
Db2175eb86669d396b8596d11478f5ef?d=identicon&s=25 Cayce Balara (yardboy)
on 2008-10-08 15:25
Nobuyoshi Nakada wrote:
> Hi,
>
> At Wed, 8 Oct 2008 02:55:48 +0900,
> Cayce Balara wrote in [ruby-talk:317108]:
>> em.cpp(1193) : error C2374: 'i' : redefinition; multiple initialization
>>         em.cpp(1186) : see declaration of 'i'
>
> It's a famous pitfall of VC6.
>
> A workaround is:
>
> #if defined __cplusplus && defined _MSC_VER && _MSC_VER == 1200
> #define for if (1) for
> #endif

THANKS. But... and sorry for being an uninformed twit here... where
exactly do I add that code? I've googled a bit and can't seem to get
detail info.
Db2175eb86669d396b8596d11478f5ef?d=identicon&s=25 Cayce Balara (yardboy)
on 2008-10-08 15:34
Okay, so messed around - tried to add the code above to the em.cpp file
that comes with gem source code but it gets over-written when the new
sources come down and would be impractical to implement on an ongoing
basis.

I added the code to my windows.h VC6 source file and was able to
complete a "gem install eventmachine" successfully.

WOOT!

However - I'd appreciate any advice on whether that's the best place to
put the code or if there is another more appropriate file for it.

Thanks so much!
This topic is locked and can not be replied to.