# Ruby for Windows Mobile (Win CE, CeGCC)

**URL:** <https://www.ruby-forum.com/t/ruby-for-windows-mobile-win-ce-cegcc/191628>\
**Category:** Ruby\
**Created:** [July 15, 2010, 3:55pm UTC](https://www.ruby-forum.com/t/ruby-for-windows-mobile-win-ce-cegcc/191628 "2010-07-15T15:55:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![axe1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ecc23a/32.png) [@axe1](https://www.ruby-forum.com/u/axe1)\
**Post date:** [July 15, 2010, 3:55pm UTC](https://www.ruby-forum.com/t/ruby-for-windows-mobile-win-ce-cegcc/191628/1 "2010-07-15T15:55:42Z")

</div>

Hi,  
I’m spent countless time in searching working ruby port on Windows  
Mobile. I’m not a fan of this OS, but already have device with it and  
still want to try programming in ruby on it. Google kicked me to:

1. Howto compile and binaries ruby 1.8.x with Microsoft Visual Embedded  
C++ ( [ruby-mswince](http://uema2.s8.xrea.com/ruby-mswince/) ). This works fine, but  
first of all it has Windows Mobile restriction on relative paths (ex.  
requiring 'lib/some.rb" - fails) and in addition it is 1.8 - not 1.9.  
There is no chance to use it as full value port, especially with  
rubygems.

2. Success story of compiling ruby 1.8 with CeGCC cross compile  
toolchain ( [http://cegcc.sourceforge.net/](http://cegcc.sourceforge.net/) ). Here is the topic of John  
Snowdon aka smed: [Ruby on WinCE / cegcc - Ruby - Ruby-Forum](http://www.ruby-forum.com/topic/143475) . He  
successfully compiled ruby 1.8 even with rubygems (!). But for my sorry  
I can’t reproduce his success and his blog with binaries is down too (  
[http://www.target-earth.net/gadgets/code/rubyce.html](http://www.target-earth.net/gadgets/code/rubyce.html) ). In addition it  
is 1.8 branch and it will be more likely to use 1.9.x 😛

So, i’m trying to compile ruby 1.9.1 p429 with CeGCC 0.59.1 under  
Ubuntu 10.04. First trouble that I get - is that confuigure script can’t  
verify setpgrp() while cross-compiling. I solve it by adding  
“ac\_cv\_func\_setpgrp\_void=yes” to args. Next trouble was that configure  
script cannot detect pthread\_kill function in any header, so it suggest  
not to use native threads, but in 1.9.x native threads - are mandatory.  
Some search kick me to mail list with howto compile pthreads-win32 (  
[The Pthreads-win32 Archives](http://sourceware.org/ml/pthreads-win32/) ) with mingw32ce (mingw32 part  
of cegcc). I reproduced his success and now i have .dll, .a and headers.  
First my question is - can I it ( library compiled with mingw32ce) in  
compiling with cegcc? I’m novice in cross compiling and it would be  
greate if someone can hint how do I use it in compilng: some extra  
environment variable, makefile edits or maybe i can add some args to  
configure script? I think i choose dirty incorrect way, trying to hack  
makefile and sources in order to bypass errors. I added  
“-I/path/to/pthreads” to optflags variable in Makefile. I’m compiling  
with this environment:  
ruby sources is in: /var/tmp/ruby-1.9.1-p429  
pthreads-win32 sources, library file(.a) and its dll in:  
/var/tmp/pthreads-w32-2-8-0-release  
cegcc is in: /opt/cegcc  
mingw32ce is in: /opt/mingw32ce

this is my PATH env variable:  
/opt/mingw32ce/bin:/opt/cegcc/bin:/opt/cegcc/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/opt/android-sdk-linux\_86/tools

and this is line with which i’m compiling:  
CC=arm-cegcc-gcc CPP=arm-cegcc-cpp AR=arm-cegcc-ar AS=arm-cegcc-as  
OBJCOPY=arm-cegcc-objcopy OBJDUMP=arm-cegcc-objdump  
RANLIB=arm-cegcc-ranlib LIBS=“-I/var/tmp/pthreads-w32-2-8-0-release  
-I/opt/cegcc/include -I/opt/cegcc/arm-cegcc/include”  
LDFLAGS=“-L/var/tmp/pthreads-w32-2-8-0-release -L/opt/cegcc/lib  
-L/opt/cegcc/arm-cegcc/lib” ./configure --host=arm-wince  
–prefix=/WinCE/built --enable-shared ac\_cv\_func\_setpgrp\_void=yes  
–enable-pthread=pthread

and this is my output:

axe1@axe1-desktop:/var/tmp/ruby-1.9.1-p429$ make  
GNUmakefile:43: target `ruby.rc’ given more than once in the same rule.  
include-dir . --include-dir . --include-dir ./win32 ruby.rc ruby.res.o  
make: include-dir: Command not found  
make: [ruby.res.o] Error 127 (ignored)  
arm-cegcc-gcc -O2 -I/var/tmp/pthreads-w32-2-8-0-release -g -Wall  
-Wno-parentheses -I. -I.ext/include/arm-wince -I./include -I.  
-DRUBY\_EXPORT -o io.o -c io.c  
io.c: In function ‘rb\_io\_close\_read’:  
io.c:3369: warning: implicit declaration of function ‘rb\_w32\_is\_socket’  
io.c: In function ‘pipe\_open’:  
io.c:4643: warning: implicit declaration of function ‘rb\_w32\_aspawn’  
io.c:4643: error: ‘P\_NOWAIT’ undeclared (first use in this function)  
io.c:4643: error: (Each undeclared identifier is reported only once  
io.c:4643: error: for each function it appears in.)  
io.c:4644: warning: implicit declaration of function ‘rb\_w32\_spawn’  
io.c: In function ‘io\_cntl’:  
io.c:6709: warning: implicit declaration of function ‘ioctl’  
io.c: In function ‘maygvl\_copy\_stream\_wait\_read’:  
io.c:7351: warning: implicit declaration of function ‘select’  
make: \*\*\* [io.o] Error 1

can anybody kick me to right way on solving this? I couldn’t understand  
why ruby uses some _w32_ function when i’m compiling with posix  
compilant toolchain…

P.S. Sorry for my bad english - my native language is russian.

---

<div class="post-metadata">

**Author:** ![axe1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ecc23a/32.png) [@axe1](https://www.ruby-forum.com/u/axe1)\
**Post date:** [July 15, 2010, 4:18pm UTC](https://www.ruby-forum.com/t/ruby-for-windows-mobile-win-ce-cegcc/191628/2 "2010-07-15T16:18:27Z")

</div>

Maxim Sokolovsky wrote:

> Hi,  
> I’m spent countless time in searching working ruby port on Windows  
> Mobile. I’m not a fan of this OS, but already have device with it and  
> still want to try programming in ruby on it. Google kicked me to:
> 
> 1. Howto compile and binaries ruby 1.8.x with Microsoft Visual Embedded  
> C++ ( [ruby-mswince](http://uema2.s8.xrea.com/ruby-mswince/) ). This works fine, but  
> first of all it has Windows Mobile restriction on relative paths (ex.  
> requiring 'lib/some.rb" - fails) and in addition it is 1.8 - not 1.9.  
> There is no chance to use it as full value port, especially with  
> rubygems.
> 
> 2. Success story of compiling ruby 1.8 with CeGCC cross compile  
> toolchain ( [http://cegcc.sourceforge.net/](http://cegcc.sourceforge.net/) ). Here is the topic of John  
> Snowdon aka smed: [Ruby on WinCE / cegcc - Ruby - Ruby-Forum](http://www.ruby-forum.com/topic/143475) . He  
> successfully compiled ruby 1.8 even with rubygems (!). But for my sorry  
> I can’t reproduce his success and his blog with binaries is down too (  
> [http://www.target-earth.net/gadgets/code/rubyce.html](http://www.target-earth.net/gadgets/code/rubyce.html) ). In addition it  
> is 1.8 branch and it will be more likely to use 1.9.x 😛
> 
> So, i’m trying to compile ruby 1.9.1 p429 with CeGCC 0.59.1 under  
> Ubuntu 10.04. First trouble that I get - is that confuigure script can’t  
> verify setpgrp() while cross-compiling. I solve it by adding  
> “ac\_cv\_func\_setpgrp\_void=yes” to args. Next trouble was that configure  
> script cannot detect pthread\_kill function in any header, so it suggest  
> not to use native threads, but in 1.9.x native threads - are mandatory.  
> Some search kick me to mail list with howto compile pthreads-win32 (  
> [The Pthreads-win32 Archives](http://sourceware.org/ml/pthreads-win32/) ) with mingw32ce (mingw32 part  
> of cegcc). I reproduced his success and now i have .dll, .a and headers.  
> First my question is - can I it ( library compiled with mingw32ce) in  
> compiling with cegcc? I’m novice in cross compiling and it would be  
> greate if someone can hint how do I use it in compilng: some extra  
> environment variable, makefile edits or maybe i can add some args to  
> configure script? I think i choose dirty incorrect way, trying to hack  
> makefile and sources in order to bypass errors. I added

If it’s a dll it “should” work.

> io.c:3369: warning: implicit declaration of function ‘rb\_w32\_is\_socket’

I think this means that somehow compilation doesn’t realize you are on  
windows.  
The rubyinstaller list might be helpful, as well.

> **[RubyInstaller for Windows](https://rubyinstaller.org/)**
>
> The easy way to install Ruby on Windows This is a self-contained Windows-based installer that includes the Ruby language, an execution environment, important...

I think I remember wince being removed recently from 1.9 branch (no  
maintainer, little interest), so grabbing a build _before_ that might  
work better. But I don’t remember exactly.

---

<div class="post-metadata">

**Author:** ![axe1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ecc23a/32.png) [@axe1](https://www.ruby-forum.com/u/axe1)\
**Post date:** [July 16, 2010, 10:14am UTC](https://www.ruby-forum.com/t/ruby-for-windows-mobile-win-ce-cegcc/191628/3 "2010-07-16T10:14:16Z")

</div>

Roger P. wrote:

> If it’s a dll it “should” work.

How do I add it in a right way? When I add it to LDFLAGS and LIBS env  
variables it doesn’t apear in compiling… So it runs like:  
arm-cegcc-gcc -O2 -g -Wall -Wno-parentheses -I.  
-I.ext/include/arm-wince -I./include -I. -DRUBY\_EXPORT -o io.o -c io.c  
I fix it dirty by adding “-I/path/to/pthreads” into Makefile in a line,  
where -O2 parameter added… How this could be done in right manner?

> I think this means that somehow compilation doesn’t realize you are on  
> windows.

I’m on Ubuntu linux if you mean my OS. And as far as i know configure  
script should think i compile it for linux, cause cegcc emulates POSIX  
API and is designed to cross-compile linux apps to windows mobile. So i  
couldn’t understand why it tries some _w32_ functions…

> The rubyinstaller list might be helpful, as well.  
> [http://rubyinstaller.org/](http://rubyinstaller.org/)

I’ll post my message there if I wouldn’t get answers here, but… they  
use MinGW32 environment to compile ruby for Win32… This isn’t near my  
goal I think, isn’t it?

> I think I remember wince being removed recently from 1.9 branch (no  
> maintainer, little interest), so grabbing a build _before_ that might  
> work better. But I don’t remember exactly.

It’s true. Sorry I forgot to say that I already tries to compile latest  
ruby 1.9.x branch without removed WinCE scripts (it’s 1.9.0.5,  
[GitHub - ruby/ruby at v1\_9\_0\_5](http://github.com/ruby/ruby/tree/v1_9_0_5)). First of all it seems that  
WinCE folder there is unchanged since 1.8.x branch and it doesn’t  
compiles. In addition it uses Microsoft Embedded Visual C++ compiler to  
build. And at [ruby-mswince](http://uema2.s8.xrea.com/ruby-mswince) is 1.8.x branch  
compiled with official support.

---

<div class="post-metadata">

**Author:** ![axe1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ecc23a/32.png) [@axe1](https://www.ruby-forum.com/u/axe1)\
**Post date:** [July 16, 2010, 4:35pm UTC](https://www.ruby-forum.com/t/ruby-for-windows-mobile-win-ce-cegcc/191628/4 "2010-07-16T16:35:22Z")

</div>

Maxim Sokolovsky wrote:

> Roger P. wrote:
> 
> > If it’s a dll it “should” work.
> 
> How do I add it in a right way? When I add it to LDFLAGS and LIBS env  
> variables it doesn’t apear in compiling… So it runs like:  
> arm-cegcc-gcc -O2 -g -Wall -Wno-parentheses -I.  
> -I.ext/include/arm-wince -I./include -I. -DRUBY\_EXPORT -o io.o -c io.c  
> I fix it dirty by adding “-I/path/to/pthreads” into Makefile in a line,  
> where -O2 parameter added… How this could be done in right manner?

is there an --enable-pthreads option? I know 1.9.2 used to try to use  
pthreads on windows but then we complained so it was disallowed…

> > I think this means that somehow compilation doesn’t realize you are on  
> > windows.
> 
> I’m on Ubuntu linux if you mean my OS. And as far as i know configure  
> script should think i compile it for linux, cause cegcc emulates POSIX  
> API and is designed to cross-compile linux apps to windows mobile. So i  
> couldn’t understand why it tries some _w32_ functions…

Something isn’t detecting right, or it would never even try to build  
win32.c, I imagine.

> > The rubyinstaller list might be helpful, as well.  
> > [http://rubyinstaller.org/](http://rubyinstaller.org/)
> 
> I’ll post my message there if I wouldn’t get answers here, but… they  
> use MinGW32 environment to compile ruby for Win32… This isn’t near my  
> goal I think, isn’t it?

Yeah but they may have some expertise.  
Unfortunately I don’t really 🙂  
-r
