# Msys w/ FXRuby

**URL:** <https://rubytalk.org/t/msys-w-fxruby/3725>\
**Category:** ruby-talk\
**Created:** [20 December 2002 01:38 UTC](https://rubytalk.org/t/msys-w-fxruby/3725 "2002-12-20T01:38:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Norman\_Su1](https://avatars.discourse-cdn.com/v4/letter/n/bc8723/32.png) [@Norman\_Su1](https://rubytalk.org/u/Norman_Su1)\
**Post date:** [20 December 2002 01:38 UTC](https://rubytalk.org/t/msys-w-fxruby/3725/1 "2002-12-20T01:38:03Z")

</div>

Hi, I’m currently trying to compile FXRuby 1.0.17 with the latest version of  
minGW/msys installed on Windows XP:

normsu[170]$ uname -sr  
MINGW32\_NT-5.1 1.0.8(0.46/3/2)  
normsu[171]$ gcc -v  
…  
Thread model: win32  
gcc version 3.2 (mingw special 20020817-1)

I’ve managed to compile fox-1.0.17 and ruby-1.6.8 (preview 4) without a hitch.  
(I had to change some paths for ruby though-- for example /usr/local =\>  
c:/msys/1.0/local) However, once I got to compiling FXRuby, I had to get rid  
of the -fno-strict-prototype flags being added in /ext/fox/extconf.rb because  
gcc was complaining. After that, I get farther but run into the following error:

g++ -DIMPORT -DNT -D\_\_NO\_ISOCEXT -g -O2 -DWIN32 -Iinclude -I. -IC:/msys/1.0/local/  
lib/ruby/1.6/i686-mingw32 -IC:/msys/1.0/home/normsu/FXRuby-1.0.17/ext/fox  
-DHAVE\_SYS\_TIME\_H -DHAVE\_SIGNAL\_H -IC:/msys/1.0/local/include/fox -I/usr/local/  
include -c -o opengl\_wrap.o opengl\_wrap.cpp  
opengl\_wrap.cpp: In function `VALUE FXGLViewer_readPixels(FXGLViewer*, int, int, int, int)': opengl_wrap.cpp:724:`alloca’ undeclared (first use this function)  
opengl\_wrap.cpp:724: (Each undeclared identifier is reported only once for each  
function it appears in.)  
make: \*\*\* [opengl\_wrap.o] Error 1

I scoured the mailing lists and I’ve seen some related errors with Solaris, but  
apparently no solutions. I’ve tried fiddling with ruby.h’s  
"if defined(HAVE\_ALLOCA\_H) etc." as described by Lyle in previous postings, but  
the error persists. I also tried changing some of the intern.h definitions as  
described in “list of things that can go wrong” section, but that doesn’t help  
as well.

Any ideas? Am I supposed to use a different version of ruby? Am I doing  
something incredibly stupid?

Thank you,

> **···**
>
> –  
> Norman

---

<div class="post-metadata">

**Author:** ![Tobias1](https://avatars.discourse-cdn.com/v4/letter/t/94ad74/32.png) [@Tobias1](https://rubytalk.org/u/Tobias1)\
**Post date:** [20 December 2002 12:01 UTC](https://rubytalk.org/t/msys-w-fxruby/3725/2 "2002-12-20T12:01:19Z")

</div>

On Fri, 20 Dec 2002, Norman Su wrote in comp.lang.ruby:

> g++ -DIMPORT -DNT -D\_\_NO\_ISOCEXT -g -O2 -DWIN32  
> […]  
> opengl\_wrap.cpp:724: `alloca’ undeclared (first use this function)  
> make: \*\*\* [opengl\_wrap.o] Error 1

> Any ideas?

I ran into a similar problem when I compiled a ruby extension written in  
C++ that included the header file.

see my MinGW bug report here:  
[http://sourceforge.net/tracker/index.php?func=detail&aid=645866&group\_id=2435&atid=102435](http://sourceforge.net/tracker/index.php?func=detail&aid=645866&group_id=2435&atid=102435)

Erasing the “-D\_\_NO\_ISOCEXT” from the command line helped. Hope it works  
for you, too.

Any idea why this Preprocessor symbol was added for MinGW compilation in  
the first place?

T

---

<div class="post-metadata">

**Author:** ![Lyle\_Johnson6](https://avatars.discourse-cdn.com/v4/letter/l/bb73d2/32.png) [@Lyle\_Johnson6](https://rubytalk.org/u/Lyle_Johnson6)\
**Post date:** [20 December 2002 14:02 UTC](https://rubytalk.org/t/msys-w-fxruby/3725/3 "2002-12-20T14:02:10Z")

</div>

Norman Su wrote:

> Any ideas? Am I supposed to use a different version of ruby? Am I doing  
> something incredibly stupid?

I _doubt_ this has been fixed on the (CVS) trunk or it would have been  
back-ported to the 1.6 branch. ISTR the other time we saw it was for the  
Solaris build.

I was trying to do the Right Thing ™ by using Ruby’s ALLOCA\_N() but  
this kind of hassle (for you and other users) just isn’t worth it. I’ll  
change those cases so that they use FXMALLOC (a wrapper around the  
regular malloc) for next time. As a workaround, you should be able to  
modify the code for FXGLViewer\_readPixels() to look like this:

```
 VALUE FXGLViewer_readPixels(FXGLViewer *self,FXint x,FXint y,FXint 

```

w,FXint h){  
FXuchar _buffer;  
VALUE pixels = Qnil;  
if (self-\>readPixels(buffer, x, y, w, h)) {  
FXint size = 3_w\*h;  
pixels = rb\_str\_new((char \*) buffer, size);  
FXFREE(&buffer);  
}  
return pixels;  
}

Looks like there are a few more of them in ui\_wrap.cpp. If it’s not  
clear how to hack those to use FXMALLOC() or just a regular malloc(),  
let me know and I can post some patches for those functions as well.

Hope this helps,

Lyle

P.S. I’ll take out that ‘-fno-strict-prototype’ too. That was a way to  
work around the broken Ruby header files, but since they’re fixed for  
Ruby 1.6.8 this shouldn’t be needed anymore…

---

<div class="post-metadata">

**Author:** ![Petr\_Fischer](https://avatars.discourse-cdn.com/v4/letter/p/a587f6/32.png) [@Petr\_Fischer](https://rubytalk.org/u/Petr_Fischer)\
**Post date:** [20 December 2002 15:14 UTC](https://rubytalk.org/t/msys-w-fxruby/3725/4 "2002-12-20T15:14:20Z")

</div>

I have faced the same kind of problem today. You can add:

#define alloca(size) \_\_builtin\_alloca(size)

to opnegl\_wrap.cpp and ui\_wrap.cpp.

p.f.

tested on: mingw-2.0.0-3, msys-1.0.8, ruby-1.6.8-preview4, fox-1.0.28,  
fxruby-1.0.17

Norman Su wrote:

> **···**
>
> > Hi, I’m currently trying to compile FXRuby 1.0.17 with the latest version of  
> > minGW/msys installed on Windows XP:
> > 
> > normsu[170]$ uname -sr  
> > MINGW32\_NT-5.1 1.0.8(0.46/3/2)  
> > normsu[171]$ gcc -v  
> > …  
> > Thread model: win32  
> > gcc version 3.2 (mingw special 20020817-1)
> > 
> > I’ve managed to compile fox-1.0.17 and ruby-1.6.8 (preview 4) without a hitch.  
> > (I had to change some paths for ruby though-- for example /usr/local =\>  
> > c:/msys/1.0/local) However, once I got to compiling FXRuby, I had to get rid  
> > of the -fno-strict-prototype flags being added in /ext/fox/extconf.rb because  
> > gcc was complaining. After that, I get farther but run into the following error:
> > 
> > g++ -DIMPORT -DNT -D\_\_NO\_ISOCEXT -g -O2 -DWIN32 -Iinclude -I. -IC:/msys/1.0/local/  
> > lib/ruby/1.6/i686-mingw32 -IC:/msys/1.0/home/normsu/FXRuby-1.0.17/ext/fox  
> > -DHAVE\_SYS\_TIME\_H -DHAVE\_SIGNAL\_H -IC:/msys/1.0/local/include/fox -I/usr/local/  
> > include -c -o opengl\_wrap.o opengl\_wrap.cpp  
> > opengl\_wrap.cpp: In function `VALUE FXGLViewer_readPixels(FXGLViewer*, int, int, int, int)': opengl_wrap.cpp:724: `alloca’ undeclared (first use this function)  
> > opengl\_wrap.cpp:724: (Each undeclared identifier is reported only once for each  
> > function it appears in.)  
> > make: \*\*\* [opengl\_wrap.o] Error 1
> > 
> > I scoured the mailing lists and I’ve seen some related errors with Solaris, but  
> > apparently no solutions. I’ve tried fiddling with ruby.h’s  
> > “if defined(HAVE\_ALLOCA\_H) etc.” as described by Lyle in previous postings, but  
> > the error persists. I also tried changing some of the intern.h definitions as  
> > described in “list of things that can go wrong” section, but that doesn’t help  
> > as well.
> > 
> > Any ideas? Am I supposed to use a different version of ruby? Am I doing  
> > something incredibly stupid?
> > 
> > Thank you,

---

<div class="post-metadata">

**Author:** ![NORMAN\_SU](https://avatars.discourse-cdn.com/v4/letter/n/3bc359/32.png) [@NORMAN\_SU](https://rubytalk.org/u/NORMAN_SU)\
**Post date:** [20 December 2002 18:35 UTC](https://rubytalk.org/t/msys-w-fxruby/3725/5 "2002-12-20T18:35:49Z")

</div>

> I have faced the same kind of problem today. You can add:
> 
> #define alloca(size) \_\_builtin\_alloca(size)
> 
> to opnegl\_wrap.cpp and ui\_wrap.cpp.

This worked great! Thanks so much.

Just to let you guys know that, unfortunantely, taking out the  
“-D\_\_NO\_ISOCEXT” did not solve the problem:

gcc -DIMPORT -DNT -g -O2 -fpermissive -DWIN32 -Iinclude -I. -IC:/msys/1.0/h  
ome/normsu/local/lib/ruby/1.6/i686-mingw32 -IC:/msys/1.0/home/normsu/src/FXR  
uby-1.0.17/ext/fox -DHAVE\_SYS\_TIME\_H -DHAVE\_SIGNAL\_H -IC:/msys/1.0/home/no  
rmsu/local/include/fox -I/usr/local/include -c -o librb.o librb.c  
In file included from  
C:/msys/1.0/home/normsu/local/lib/ruby/1.6/i686-mingw32/defines.h:36,  
from  
C:/msys/1.0/home/normsu/local/lib/ruby/1.6/i686-mingw32/ruby.h:22,  
from librb.c:212:  
C:/msys/1.0/home/normsu/local/lib/ruby/1.6/i686-mingw32/win32/win32.h:225:  
parse error before “sizeof”  
C:/msys/1.0/home/normsu/local/lib/ruby/1.6/i686-mingw32/win32/win32.h:226:  
parse error before “sizeof”  
make: \*\*\* [librb.o] Error 1

I did not try out Lyle’s suggestion, since the other one worked =) One more  
question, are FXRuby versions ONLY compatible with their equivalent  
versions? For example if I use FXRuby-1.0.17, does that mean I can ONLY use  
it with Fox version 1.0.17, or is it ok to use newer versions like 1.0.28?  
(so far 1.0.28 seems to work fine with FXRuby-1.0.17)

Thanks,

> **···**
>
> –  
> Norman

---

<div class="post-metadata">

**Author:** ![Lyle\_Johnson6](https://avatars.discourse-cdn.com/v4/letter/l/bb73d2/32.png) [@Lyle\_Johnson6](https://rubytalk.org/u/Lyle_Johnson6)\
**Post date:** [20 December 2002 18:55 UTC](https://rubytalk.org/t/msys-w-fxruby/3725/6 "2002-12-20T18:55:53Z")

</div>

NORMAN SU wrote:

> I did not try out Lyle’s suggestion, since the other one worked =)

A pragmatic choice 😉

But I did go ahead and made those fixes for the next release, so that in  
the future people won’t have to modify those compiler flags.

> One more question, are FXRuby versions ONLY compatible with their equivalent  
> versions? For example if I use FXRuby-1.0.17, does that mean I can ONLY use  
> it with Fox version 1.0.17, or is it ok to use newer versions like 1.0.28?  
> (so far 1.0.28 seems to work fine with FXRuby-1.0.17)

Any FXRuby-1.0.x release should work with any fox-1.0.x release. So yes,  
it is fine to use fox-1.0.28 and FXRuby-1.0.17 together.
