# Building Windows C Extension

**URL:** <https://www.ruby-forum.com/t/building-windows-c-extension/139542>\
**Category:** Ruby\
**Created:** [June 4, 2008, 9:06pm UTC](https://www.ruby-forum.com/t/building-windows-c-extension/139542 "2008-06-04T21:06:46Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Scott\_Preston](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d2c977/32.png) [@Scott\_Preston](https://www.ruby-forum.com/u/Scott_Preston)\
**Post date:** [June 4, 2008, 9:06pm UTC](https://www.ruby-forum.com/t/building-windows-c-extension/139542/1 "2008-06-04T21:06:46Z")

</div>

All,

I am sure this has been brought up before but I am having problems  
writing a simple hello word C extension for Ruby in Windows.

I am able to use nmake to build the library but get:

a C++ popup with R6034 Load Error / (DLL) initialization routine  
failed…1.8/i386-msvcrt/mytest.so (LoadError)…

In trying to use MinGW, it does not like the makefile generated by  
extconf.rb, and gets hung up on the colon in the topdir. relative  
pathing does not work

So I am out of luck on both accounts.

Any help appriciated.

Thanks,  
Scott

---

<div class="post-metadata">

**Author:** ![Scott\_Preston](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d2c977/32.png) [@Scott\_Preston](https://www.ruby-forum.com/u/Scott_Preston)\
**Post date:** [June 4, 2008, 9:28pm UTC](https://www.ruby-forum.com/t/building-windows-c-extension/139542/2 "2008-06-04T21:28:42Z")

</div>

Building an extension on Windows can be an exercise in frustration.  
The biggest problem is that Windows Ruby is still built with VC6 and  
thus extensions built with any later technology probably won’t work.

The best way I’ve done it is through Cygwin. There are ways of getting  
mingw to work, but it’s not pretty and not guarenteed. With the  
One-Click Installer, try the following:

CPPFLAGS=-D\_MSC\_VER=1200 LIBS=-lmsvcp60 ./configure

then see if the compilation will work for you.

Jason

---

<div class="post-metadata">

**Author:** ![Scott\_Preston](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d2c977/32.png) [@Scott\_Preston](https://www.ruby-forum.com/u/Scott_Preston)\
**Post date:** [June 4, 2008, 9:52pm UTC](https://www.ruby-forum.com/t/building-windows-c-extension/139542/3 "2008-06-04T21:52:54Z")

</div>

post the error message to the one click installer if you’d like help  
with mingw 🙂

> In trying to use MinGW, it does not like the makefile generated by  
> extconf.rb, and gets hung up on the colon in the topdir. relative  
> pathing does not work

---

<div class="post-metadata">

**Author:** ![Scott\_Preston](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d2c977/32.png) [@Scott\_Preston](https://www.ruby-forum.com/u/Scott_Preston)\
**Post date:** [June 4, 2008, 9:54pm UTC](https://www.ruby-forum.com/t/building-windows-c-extension/139542/4 "2008-06-04T21:54:08Z")

</div>

Thanks Jason I will give this a try.

Cheers,  
Scott

---

<div class="post-metadata">

**Author:** ![Scott\_Preston](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d2c977/32.png) [@Scott\_Preston](https://www.ruby-forum.com/u/Scott_Preston)\
**Post date:** [June 4, 2008, 10:27pm UTC](https://www.ruby-forum.com/t/building-windows-c-extension/139542/5 "2008-06-04T22:27:46Z")

</div>

Scott Preston wrote:

> the error I get from the make via mingw is:
> 
> \*\*\* target pattern contains no `%’. Stop.

for me this means that cygwin’s path is before my mingw path. Putting  
mingw at the front helped.  
GL.  
-R

---

<div class="post-metadata">

**Author:** ![Scott\_Preston](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d2c977/32.png) [@Scott\_Preston](https://www.ruby-forum.com/u/Scott_Preston)\
**Post date:** [June 5, 2008, 3:15pm UTC](https://www.ruby-forum.com/t/building-windows-c-extension/139542/6 "2008-06-05T15:15:46Z")

</div>

I installed an old copy of visual studio 6, compiled my extension with  
VC6 and everything worked.

Thanks all for your responses.

Cheers,  
Scott

---

<div class="post-metadata">

**Author:** ![Scott\_Preston](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d2c977/32.png) [@Scott\_Preston](https://www.ruby-forum.com/u/Scott_Preston)\
**Post date:** [June 4, 2008, 10:25pm UTC](https://www.ruby-forum.com/t/building-windows-c-extension/139542/7 "2008-06-04T22:25:26Z")

</div>

the error I get from the make via mingw is:

\*\*\* target pattern contains no `%’. Stop.
