Index of UNOFFICIAL Circumvesuviana Home Page La mia tesi di laurea main index I'm sure I'm not the first man in the universe who compiled Ruby (*) on a 64-bit 8-processors 20Gb-RAM machine sporting an Oracle 8 server; but I think that adding some notes here could be someday useful to someone... :-)

(*) Ruby (named after the precious purplish-red corundum stone) is the excellent object-oriented scripting language created by Yukihiro "Matz" Matsumoto.

First: compiling and installing Ruby

In order to convince my boss to use Ruby, I compiled Ruby 1.8.2 on our HP-Unix PARISC2.0 server machine (architecture hppa2.0w-hp-hpux11.11) with Oracle 8.1.7 installed.

On the target machine there isn't the gcc compiler. So the Ruby source configure script was successfully executed when called as:
./configure --prefix=$HOME --enable-install-doc --without-gcc --enable-pthread

Note: I preferred to have it in my $HOME/usr/bin to not to invade other people space. I also want all documentation installed. I had to explicitly disable gcc because we here have a gcc executable in the $PATH that expects some data from standard input (thus blocking the ./configure script). Finally, we here traditionally compile with pthread library every executable.

Then, calling "make", I got an error: config.status: creating Makefile
Makefile updated, restart.
*** Error exit code 1

No problem! Just call "make" again to start compiling Ruby source.

On the target machine there is no gperf (apparently needed to compile Ruby package): after starting make the lex.c source file becomes zero bytes, thus generating compiler errors. But when the make stopped, I was able to continue using the original lex.c from the source package and "touching" it to appear as newly created:
cd ..
tar xf ruby-1.8.2.tar ruby-1.8.2/lex.c
cd ruby-1.8.2
touch lex.c
make install

During compilation I got a large number of warnings, mainly of two types - mismatching pointers (it seems that the cc coming with HP-UX 11.11 doesn't like assigning a void-pointer value to a non-void pointer and vice versa; I think it's just a "C++ style" check) and redeclarations (at least, the cc says so); for example:
cc: "nkf-utf8/nkf.c", line 1823: warning 562: Redeclaration of "kanji_convert" with a different storage class specifier: "kanji_convert" will have internal linkage.

cc: "digest.c", line 100: warning 604: Pointers are not assignment-compatible.
cc: "digest.c", line 100: warning 563: Argument #2 is not the correct type.

Anyways, it will compile Ruby without major errors; the test unit also was successful:
cd usr/lib/ruby/1.8/test
ruby unit.rb

Loaded suite unit

Finished in 0.000982 seconds.

0 tests, 0 assertions, 0 failures, 0 errors

So I expect Ruby to run correctly on this machine (architecture is "hppa2.0w-hp-hpux11.11").

Installing Ruby/OCI8 (Oracle Call Interface)

I tried to install the Ruby OCI8 package by Takehiro Kubo. These notes are related to the 0.1.11 version.

First problem: missing zlib

ruby-oci8-0.1.11/metaconfig:3:in `require': No such file to load -- zlib (LoadError)

This is because the installed version of Ruby didn't have zlib package installed. I solved this by erasing in the metaconfig the require 'zlib' line (the zlib is not needed to compile and install).

Second problem: ./configure

checking for OCIInitialize()... no
cannot compile OCI

Well, this is because I compiled Ruby (and thus its libraries) with CFLAGS="+DS2.0W +DA2.0W" (I know it's a bad habit, and it's only to save an ld warning at compile time, as we here don't have any PA 1.x systems)).

I just recompiled Ruby without the above CFLAGS, and then ruby-oci8 was compiled without further errors (except the zlib one corrected as above); there were a number of compile warnings, but we all know the cc compiler of HP-UX 11.11 is a bit hairy. The OCI8 library was finally compiled and installed.

Third problem: dlopen

When a ruby source requires 'oci8', a weird error happens:

Can't dlopen() a library containing Thread Local Storage: /usr/lib/libpthread.1 - .../ (LoadError)" -- from oci8.rb:7

As of HP-UX documentation, this happens because I compiled the ruby-oci8 library without the +tls=dynamic compiler option. But I found that the Ansi cc featured in HP-UX 11.11 does not have that switch. So I simply had to ask the loader to "pre-load" the library; for example, to start irb I typed in:
LD_PRELOAD=$HOME/usr/lib/ruby/site_ruby/1.8/hppa2.0w-hpux11.11/ irb

This is anyways quite ugly; Takehiro suggested me to recompile Ruby, adding -lcl to the LIBS line of the Makefile soon after ./configure and just before compiling. YAY! it was good. Compile and install went OK.

And finally...

D'oh! Let's try a query. I entered this small program (both ruby and irb):
require 'oci8'
o ='scott', 'tiger', '')
curs = o.exec('select nome,cognome,manie_di_grandezza from testoni where rownum < 15')
while r = curs.fetch()
  puts r.join(',')

And -yeah!- it ran great! :-) Now I can bother my boss trying to convince him to let me leave that ugly Pro*C (and awk and perl and ksh and...) for everyday work... Will I have success? :-) More news in next months... stay tuned! :-)

Apple notes: in some versions of Mac OS X with ruby 1.8.1 or ruby 1.8.2 installed you need to erase the -arch i386 flags in the CFLAGS and LDFLAGS definitions in the default rbconfig.rb file, editing it with the command:
sudo vi /usr/lib/ruby/1.8/powerpc-darwin8.0/rbconfig.rb
(you may not be able to compile ruby-oci8 on Apple Mac OS X if you don't change that bug in the configuration definitions!)

Tornando in stazione a prendere il treno...

home page - send e-mail