# Cross Compiling Ruby external modules for the Nokia 770

**URL:** <https://www.ruby-forum.com/t/cross-compiling-ruby-external-modules-for-the-nokia-770/72128>\
**Category:** Ruby\
**Created:** [February 23, 2006, 1:13am UTC](https://www.ruby-forum.com/t/cross-compiling-ruby-external-modules-for-the-nokia-770/72128 "2006-02-23T01:13:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kenosis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f04885/32.png) [@Kenosis](https://www.ruby-forum.com/u/Kenosis)\
**Post date:** [February 23, 2006, 1:13am UTC](https://www.ruby-forum.com/t/cross-compiling-ruby-external-modules-for-the-nokia-770/72128/1 "2006-02-23T01:13:56Z")

</div>

Greetings,

I’ve had several request to update my Ruby “release” for the Nokia 770  
to include gems. Gems, as I understand it, requires a few external  
components to be compiled into Ruby, e.g., openssl, stringio, etc.; and  
of course modifying ext/Setup accordingly works flawlessly on Windows  
and Linux flavors. Unfortunately, I’m having trouble making the same  
mods to my Maemo cross compiled version of Ruby and I’m hoping someone  
might be able to diagnose the problem I’m having (its escaping me, I’m  
sorry to say ☹ So… I’ve tried this several times, several  
different ways all w/the same outcome. Also of note is that because  
the Nokia 770 linux distro is highly pruned down, I’m compiling ruby  
and the necessary external components as static, ie, non-dynamic, so  
all necessary extermal libs are linked into the resultant Ruby.

Thx in advance!

Ken

Starting from a clean untar of Ruby 184, we do the following:

1. Edit ext/Setup - notice nodymaic is uncommented and only openssl and  
stringio are uncommented.

option nodynamic

#Win32API  
#bigdecimal  
#curses  
#dbm  
#digest  
#digest/md5  
#digest/rmd160  
#digest/sha1  
#digest/sha2  
#dl  
#enumerator  
#etc  
#fcntl  
#gdbm  
#iconv  
#io/wait  
#nkf  
#pty  
openssl  
#racc/cparse  
#readline  
#sdbm  
#socket  
stringio  
#strscan  
#syck  
#syslog  
#tcltklib  
#tk  
#win32ole  
#zlib

1. ./configure --with-static-linked-ext # config finishes w/out  
incident.

2. make # Ruby and openssl compile fine but when (what appear to be)  
openssl dependencies begin to compile, we get the following:

make[1]: Leaving directory `/home/ken/ruby-1.8.4/ext/digest/sha2' compiling dl make[1]: Entering directory `/home/ken/ruby-1.8.4/ext/dl' gcc -g -O2 -fno-defer-pop -fno-omit-frame-pointer -I. -I../.. -I/home/ken/ruby-1.8.4 -I/home/ken/ruby-1.8.4/ext/dl -DRUBY\_EXPORT -DHAVE\_DLFCN\_H -DHAVE\_DLOPEN -DHAVE\_DLCLOSE -DHAVE\_DLSYM -DHAVE\_DLERROR -I. -c sym.c gcc -g -O2 -fno-defer-pop -fno-omit-frame-pointer -I. -I../.. -I/home/ken/ruby-1.8.4 -I/home/ken/ruby-1.8.4/ext/dl -DRUBY\_EXPORT -DHAVE\_DLFCN\_H -DHAVE\_DLOPEN -DHAVE\_DLCLOSE -DHAVE\_DLSYM -DHAVE\_DLERROR -I. -c handle.c gcc -g -O2 -fno-defer-pop -fno-omit-frame-pointer -I. -I../.. -I/home/ken/ruby-1.8.4 -I/home/ken/ruby-1.8.4/ext/dl -DRUBY\_EXPORT -DHAVE\_DLFCN\_H -DHAVE\_DLOPEN -DHAVE\_DLCLOSE -DHAVE\_DLSYM -DHAVE\_DLERROR -I. -c ptr.c gcc -g -O2 -fno-defer-pop -fno-omit-frame-pointer -I. -I../.. -I/home/ken/ruby-1.8.4 -I/home/ken/ruby-1.8.4/ext/dl -DRUBY\_EXPORT -DHAVE\_DLFCN\_H -DHAVE\_DLOPEN -DHAVE\_DLCLOSE -DHAVE\_DLSYM -DHAVE\_DLERROR -I. -c dl.c In file included from dl.c:104: callback.func:1: error: parse error before '(' token callback.func:1: error: parse error before ')' token callback.func:3: error: parse error before '(' token callback.func:3: error: parse error before ')' token callback.func:4: error: `proc' undeclared here (not in a function) callback.func:4: error: `argc' undeclared here (not in a function) callback.func:4: error: `argv' undeclared here (not in a function) callback.func:4: error: initializer element is not constant callback.func:4: warning: data definition has no type or storage class callback.func:6: error: parse error before "return" callback.func:9: warning: data definition has no type or storage class callback.func:14: error: conflicting types for `buff' callback.func:12: error: previous declaration of `buff'

Checking out the (apparently) dynamically generated file  
“callback.func”, we see the following (no, this isn’t a copy and past  
error - the file begins on line 1 w/ “f( RSTRING(proto)-\>len \>= 15 )”.  
Any idea why this file would be incomplete/corrupt? Is there another  
parameter I need to perhaps pass to “configure” that pertains to  
statically “building” Ruby?

f( RSTRING(proto)-\>len \>= 15 )  
rb\_raise(rb\_eArgError, “too many arguments”);  
rb\_dl\_scan\_callback\_args(buff, RSTRING(proto)-\>ptr, &argc, argv);  
retval = rb\_funcall2(proc, id\_call, argc, argv);

return rb\_dlptr2cptr(retval);  
}

obj;  
VALUE argv[15];  
int argc;  
long buff[15];

buff[0] = arg0;  
buff[1] = arg1;  
buff[2] = arg2;  
buff[3] = arg3;  
buff[4] = arg4;  
buff[5] = arg5;  
buff[6] = arg6;  
buff[7] = arg7;  
buff[8] = arg8;  
buff[9] = arg9;  
buff[10] = arg10;  
buff[11] = arg11;  
buff[12] = arg12;  
buff[13] = arg13;  
buff[14] = arg14;

obj = rb\_hash\_aref(DLFuncTable, rb\_assoc\_new(INT2NUM(0),INT2NUM(0)));  
proto = rb\_ary\_entry(obj, 0);  
proc = rb\_ary\_entry(obj, 1);  
Check\_Type(proto, T\_STRING);  
if( RSTRING(proto)-\>len \>= 15 )  
rb\_raise(rb\_eArgError, “too many arguments”);  
rb\_dl\_scan\_callback\_args(buff, RSTRING(proto)-\>ptr, &argc, argv);  
retval = rb\_funcall2(proc, id\_call, argc, argv);

/\* no return value \*/  
}
