# Win32 environment for ruby extension work

**URL:** <https://www.ruby-forum.com/t/win32-environment-for-ruby-extension-work/79053>\
**Category:** Ruby\
**Created:** [December 11, 2006, 10:11pm UTC](https://www.ruby-forum.com/t/win32-environment-for-ruby-extension-work/79053 "2006-12-11T22:11:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ross\_b](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8edcca/32.png) [@ross\_b](https://www.ruby-forum.com/u/ross_b)\
**Post date:** [December 11, 2006, 10:11pm UTC](https://www.ruby-forum.com/t/win32-environment-for-ruby-extension-work/79053/1 "2006-12-11T22:11:51Z")

</div>

Hi,

I’ve recently been attempting to look at Win32 compatibility on the  
various C extensions I work on, but in my ignorance I’m getting a bit  
confused (Microsoft’s site seems designed to promote that ☹ ). I could  
use a little help from someone who knows about these things.

To cut a (very) long story short, here’s what I need to know:

1. I now gather that the VC 2005 I downloaded isn’t going to cut it if I  
want to target the one-click installer. I can compile, but not use,  
extensions with it. I gather I need VC 6? Please tell me I’m wrong about  
this, but isn’t that going to cost actual money? Is there a free  
download  
for it that I’ve missed?

2. Should I be targeting the one-click installer? It seems like it’s the  
most commonly used on Windows, and for testing it’s probably irrelevant,  
but I’d like to do precompiled binaries for win32 as well - should they  
target the one-click, or something else?

3. Am I going to run into similar problems with multiple runtime  
environments when using e.g. libxml-ruby, given that it’s dependencies  
may  
be compiled with a different compiler. Should I be expecting any gotchas  
when (if) I get to that stage?

I’m sure there are great resources out there, but I have a bit of  
information overload and I’m struggling to sort the wheat from the chaff  
on this one. Any help or links to helpful resources would be very much  
appreciated.

Thanks,

---

<div class="post-metadata">

**Author:** ![ross\_b](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8edcca/32.png) [@ross\_b](https://www.ruby-forum.com/u/ross_b)\
**Post date:** [December 11, 2006, 10:42pm UTC](https://www.ruby-forum.com/t/win32-environment-for-ruby-extension-work/79053/2 "2006-12-11T22:42:08Z")

</div>

On 12/11/06, Ross B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 1. I now gather that the VC 2005 I downloaded isn’t going to cut it if I  
> want to target the one-click installer. I can compile, but not use,  
> extensions with it. I gather I need VC 6? Please tell me I’m wrong about  
> this, but isn’t that going to cost actual money? Is there a free download  
> for it that I’ve missed?

The compiler situation on Windows is currently a mess. Read this to help  
understand the issues:

[You are in a maze of twisty little passages, all alike. // halo • statue](http://www.halostatue.ca/2006/09/21/ruby-on-windows-a-note-for-microsoft/)

You should be able to use VC 6 (if you can find a copy, its no longer  
available from MS) or MinGW. Either one should produce extensions  
compatible  
wit the one-click installer.

1. Should I be targeting the one-click installer? It seems like it’s the

> most commonly used on Windows, and for testing it’s probably irrelevant,  
> but I’d like to do precompiled binaries for win32 as well - should they  
> target the one-click, or something else?

Yes, you should target the one-click installer.

1. Am I going to run into similar problems with multiple runtime

> environments when using e.g. libxml-ruby, given that it’s dependencies may  
> be compiled with a different compiler. Should I be expecting any gotchas  
> when (if) I get to that stage?

If they are compiled with VC 6 or MinGW you’ll be ok. If the depdencies  
are  
compiled with other compilers you you could be ok or you could have  
problems… it just depends.

Curt

I’m sure there are great resources out there, but I have a bit of

---

<div class="post-metadata">

**Author:** ![ross\_b](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8edcca/32.png) [@ross\_b](https://www.ruby-forum.com/u/ross_b)\
**Post date:** [December 11, 2006, 10:42pm UTC](https://www.ruby-forum.com/t/win32-environment-for-ruby-extension-work/79053/3 "2006-12-11T22:42:08Z")

</div>

On 12/11/06, Ross B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi,
> 
> I’ve recently been attempting to look at Win32 compatibility on the  
> various C extensions I work on, but in my ignorance I’m getting a bit  
> confused (Microsoft’s site seems designed to promote that ☹ ). I could  
> use a little help from someone who knows about these things.

I’m not an expert, so take this as such. Sometime ago there was a  
thread on choosing compiler for OCI, you might find interesting info  
there.

AFAIK, the problem with VC8 is that it uses sidebyside, that requires  
you to put so called manifests (xml files describing dependencies)  
along your dlls. One way to work around this is to statically compile.  
Another is to install those files into a system-wide dir  
(/Windows/SxS). There is also a binary incompatibility between VC6 and  
VC7 and VC8 runtime libs (I believe they reordered functions in the  
dlls).

> To cut a (very) long story short, here’s what I need to know:
> 
> 1. I now gather that the VC 2005 I downloaded isn’t going to cut it if I  
> want to target the one-click installer. I can compile, but not use,  
> extensions with it. I gather I need VC 6? Please tell me I’m wrong about  
> this, but isn’t that going to cost actual money? Is there a free download  
> for it that I’ve missed?

IIRC mingw is binary compatible with VC6.

> 1. Should I be targeting the one-click installer? It seems like it’s the  
> most commonly used on Windows, and for testing it’s probably irrelevant,  
> but I’d like to do precompiled binaries for win32 as well - should they  
> target the one-click, or something else?

OCI uses win32 binaries from [ruby-lang.org](http://ruby-lang.org) as they are, and _they_ are  
compiled with VC6. OCI doesn’t recompile ruby itself, only the  
extensions. That relaxes a bit the question.

> 1. Am I going to run into similar problems with multiple runtime  
> environments when using e.g. libxml-ruby, given that it’s dependencies may  
> be compiled with a different compiler. Should I be expecting any gotchas  
> when (if) I get to that stage?

I was able to run VC8-compiled extension for more than year almost  
each night, although I got segfaults rarely (10 times altogether). I  
haven’t analyzed them, so I don’t know the real reason. Unfortunately  
I had to live with the manifests… The extension ifself was wrapping  
a c++ shared memory protocol - it does mostly type conversions, and  
event polling, no files.

> I’m sure there are great resources out there, but I have a bit of  
> information overload and I’m struggling to sort the wheat from the chaff  
> on this one. Any help or links to helpful resources would be very much  
> appreciated.

Now I’m not sure if I’ve added to chaff or wheat side… 😉

---

<div class="post-metadata">

**Author:** ![ross\_b](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8edcca/32.png) [@ross\_b](https://www.ruby-forum.com/u/ross_b)\
**Post date:** [December 13, 2006, 11:25am UTC](https://www.ruby-forum.com/t/win32-environment-for-ruby-extension-work/79053/4 "2006-12-13T11:25:59Z")

</div>

On Mon, 11 Dec 2006 21:40:08 -0000, Jan S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> there.
> 
> AFAIK, the problem with VC8 is that it uses sidebyside, that requires  
> you to put so called manifests (xml files describing dependencies)  
> along your dlls. One way to work around this is to statically compile.  
> Another is to install those files into a system-wide dir  
> (/Windows/SxS). There is also a binary incompatibility between VC6 and  
> VC7 and VC8 runtime libs (I believe they reordered functions in the  
> dlls).

I read a little about this, but it seemed to me at the time like a  
solution in search of a problem. I did have some problems with VC 8, in  
that nothing would work unless I copied some .dll files out from  
/windows/sxs to /windows/system32. After that I still had nothing  
working,  
but at least there was a useful error message (about some application  
trying to initialize the runtime incorrectly).

I don’t suppose you have a link that describes these manifests in more  
detail?

(Btw I do realise now that I’d taken some bad advice on copying those  
.dll  
files - I was just working through what information I could find and  
picked that up off the net somewhere I think).

> 

Ahh, ok - I’d not realised this. So assuming I make provisions to  
generate  
a correct makefile, I could compile for both testing and ready-made  
binary  
downloads using mingw, and they’d run fine against the one-click? Is  
there  
an easy way to generate a suitable makefile from the one-click’s ruby,  
or  
is it just a case of changing the Config::MAKEFILE\_CONFIG to suit?

Since I’m planning to offer ready-made binaries, I’m not too worried if  
there are hoops to jump through / local modifications to make when  
compiling it up (though it seems a shame that the compatibility  
situation  
requires this).

> > 1. Should I be targeting the one-click installer? It seems like it’s the  
> > most commonly used on Windows, and for testing it’s probably irrelevant,  
> > but I’d like to do precompiled binaries for win32 as well - should they  
> > target the one-click, or something else?
> 
> OCI uses win32 binaries from [ruby-lang.org](http://ruby-lang.org) as they are, and _they_ are  
> compiled with VC6. OCI doesn’t recompile ruby itself, only the  
> extensions. That relaxes a bit the question.

Okay, cool. So if I target the one-click, presumably I’ll be targetting  
the vast majority of windows users. Those who compile their own ruby on  
Win32 (do people actually do this? I was unable to use VS 8 even if I  
compiled a ruby with it, since the resulting ruby didn’t seem to want to  
work…).

> > I’m sure there are great resources out there, but I have a bit of  
> > information overload and I’m struggling to sort the wheat from the chaff  
> > on this one. Any help or links to helpful resources would be very much  
> > appreciated.
> 
> Now I’m not sure if I’ve added to chaff or wheat side… 😉

Definitely the wheat - twice while reading your reply I had those  
moments  
where disconnected bits of information come together in a flash, so  
thanks  
🙂 I’m off to investigate the mingw option, if nothing else it’ll save  
me  
from that [msdn.microsoft.com](http://msdn.microsoft.com) labyrinthe 😉

Cheers,

---

<div class="post-metadata">

**Author:** ![ross\_b](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8edcca/32.png) [@ross\_b](https://www.ruby-forum.com/u/ross_b)\
**Post date:** [December 14, 2006, 12:33pm UTC](https://www.ruby-forum.com/t/win32-environment-for-ruby-extension-work/79053/5 "2006-12-14T12:33:29Z")

</div>

On 12/13/06, Ross B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I read a little about this, but it seemed to me at the time like a  
> solution in search of a problem. I did have some problems with VC 8, in  
> that nothing would work unless I copied some .dll files out from  
> /windows/sxs to /windows/system32. After that I still had nothing working,  
> but at least there was a useful error message (about some application  
> trying to initialize the runtime incorrectly).
> 
> I don’t suppose you have a link that describes these manifests in more  
> detail?

I don’t have a link. I just googled and then didn’t save the link.  
Anyway, the technology is called Side by side, and there is a special  
file that you can install that will get rid of the problem… I  
believe it’s this one: “C:\Program Files\Microsoft Visual Studio  
8\SDK\v2.0\BootStrapper\Packages\vcredist\_x86\vcredist\_x86.exe” but  
I’m not sure.

> Ahh, ok - I’d not realised this. So assuming I make provisions to generate  
> a correct makefile, I could compile for both testing and ready-made binary  
> downloads using mingw, and they’d run fine against the one-click? Is there  
> an easy way to generate a suitable makefile from the one-click’s ruby, or  
> is it just a case of changing the Config::MAKEFILE\_CONFIG to suit?

I don’t know.

> Okay, cool. So if I target the one-click, presumably I’ll be targetting  
> the vast majority of windows users. Those who compile their own ruby on  
> Win32 (do people actually do this? I was unable to use VS 8 even if I  
> compiled a ruby with it, since the resulting ruby didn’t seem to want to  
> work…).

I somehow managed to compile ruby with VS8, although I didn’t test it  
too much.

For more information, you might look up Curt H.', Austin Z.'s  
and Dan B.'s posts as they seem to know the most about win  
compilation here 😉

J.
