Making/Compiling Gems on Windows with MinGW

C

Cayce Balara

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

Luis Lavena

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.

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

Cayce Balara

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.

Thanks so much for the reply and the assistance!

c.
 
A

Axel Etzold

-------- Original-Nachricht --------
Datum: Mon, 6 Oct 2008 00:36:16 +0900
Von: Cayce Balara <[email protected]>
An: (e-mail address removed)
Betreff: Re: Making/Compiling Gems on Windows with MinGW

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.


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.


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.


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


Thanks so much for the reply and the assistance!

c.

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
 
C

Cayce Balara

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. :)
 
J

James M. Lawrence

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).
 
C

Cayce Balara

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

Nobuyoshi Nakada

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
 
C

Cayce Balara

Nobuyoshi said:
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.
 
C

Cayce Balara

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top