Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Compiling native extension into Ruby

Reply
Thread Tools

Compiling native extension into Ruby

 
 
David Craine
Guest
Posts: n/a
 
      01-11-2005
--Apple-Mail-1-458716087
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
format=flowed

I'm trying to compile the BerkeleyDB ruby extension into the ruby
executable for ruby 1.8.2. I've placed the extension directory
underneath the <ruby>/ext directory. When I do configure and make the
build process tries to build the BerkleyDB extension but it fails
because it can't find the Berkeley libraries. Normally when building
this extension you have to specifiy the --with-db-dir=<db dir>
parameter when running the extconf.rb file. But I cannot figure out
how to pass this same information into the configure/make process for
ruby. Anyone have any ideas regarding this?

Dave Craine
--Apple-Mail-1-458716087--


 
Reply With Quote
 
 
 
 
ts
Guest
Posts: n/a
 
      01-11-2005
>>>>> "D" == David Craine <(E-Mail Removed)> writes:

D> ruby. Anyone have any ideas regarding this?

you don't need to put it into ruby-1.8.2/ext

* Install normally ruby

* extract bdb-0.5.4 *outside* the ruby directory

* then run

ruby extconf.rb --with-db-dir=...
make
make install


Guy Decoux



 
Reply With Quote
 
 
 
 
David Craine
Guest
Posts: n/a
 
      01-11-2005
--Apple-Mail-2-459741324
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
format=flowed

RIght...I've got that part. But what I'm trying to do is compile and
statically link the extension into the ruby executable itself. I've
created an entry in the <ruby>/ext/Setup file for bdb so that it will
try and build it when Ruby builds. When I try to make ruby it will
actually try and compile the bdb extension, but without passing in the
--with-db-dir parameter. I need to know how to pass this parameter
through to the extconf.rb file for the bdb extension when running the
make file for ruby.

Dave

On Jan 11, 2005, at 1:22 PM, ts wrote:

>>>>>> "D" == David Craine <(E-Mail Removed)> writes:

>
> D> ruby. Anyone have any ideas regarding this?
>
> you don't need to put it into ruby-1.8.2/ext
>
> * Install normally ruby
>
> * extract bdb-0.5.4 *outside* the ruby directory
>
> * then run
>
> ruby extconf.rb --with-db-dir=...
> make
> make install
>
>
> Guy Decoux
>
>
>


--Apple-Mail-2-459741324--


 
Reply With Quote
 
YANAGAWA Kazuhisa
Guest
Posts: n/a
 
      01-11-2005
In Message-Id: <(E-Mail Removed)>
David Craine <(E-Mail Removed)> writes:

> actually try and compile the bdb extension, but without passing in the
> --with-db-dir parameter. I need to know how to pass this parameter
> through to the extconf.rb file for the bdb extension when running the
> make file for ruby.


Then give the option to configure. Ruby's configure passes unknown
options to extmk.rb, which then use that options to make extension
libraries.


--
http://www.velocityreviews.com/forums/(E-Mail Removed) January 12, 2005
It is never late to mend.



 
Reply With Quote
 
ts
Guest
Posts: n/a
 
      01-12-2005
>>>>> "D" == David Craine <(E-Mail Removed)> writes:

D> RIght...I've got that part. But what I'm trying to do is compile and
D> statically link the extension into the ruby executable itself. I've
D> created an entry in the <ruby>/ext/Setup file for bdb so that it will
D> try and build it when Ruby builds. When I try to make ruby it will
D> actually try and compile the bdb extension, but without passing in the
D> --with-db-dir parameter. I need to know how to pass this parameter
D> through to the extconf.rb file for the bdb extension when running the
D> make file for ruby.

There is a bug in extconf.rb for bdb, not really a surprise for me

Try it with

uln% cd ext
uln%

uln% tar zxf ~/ruby/perso/db/bdb-0.5.4.tar.gz
uln%

uln% rm -r bdb-0.5.4/extconf.rb bdb-0.5.4/bdbxml*
uln%

uln% cd ..
uln%

uln% tail -1 ext/Setup
bdb-0.5.4/src
uln%

uln% ./configure --prefix=$HOME/local/r182 --with-db-dir=$HOME/local/db4.3.21 > /dev/null
uln%

uln% make

[...]

compiling bdb-0.5.4/src
make[1]: Entering directory `/opt/ts/ruby/tmp/ruby-1.8.2/ext/bdb-0.5.4/src'
gcc -g -O2 -I. -I../../.. -I../../../. -I../../.././ext/bdb-0.5.4/src -I/opt/ts/local/db4.3.21/include -c bdb.c
gcc -g -O2 -I. -I../../.. -I../../../. -I../../.././ext/bdb-0.5.4/src -I/opt/ts/local/db4.3.21/include -c env.c
gcc -g -O2 -I. -I../../.. -I../../../. -I../../.././ext/bdb-0.5.4/src -I/opt/ts/local/db4.3.21/include -c log.c
gcc -g -O2 -I. -I../../.. -I../../../. -I../../.././ext/bdb-0.5.4/src -I/opt/ts/local/db4.3.21/include -c transaction.c
gcc -g -O2 -I. -I../../.. -I../../../. -I../../.././ext/bdb-0.5.4/src -I/opt/ts/local/db4.3.21/include -c cursor.c
gcc -g -O2 -I. -I../../.. -I../../../. -I../../.././ext/bdb-0.5.4/src -I/opt/ts/local/db4.3.21/include -c common.c
gcc -g -O2 -I. -I../../.. -I../../../. -I../../.././ext/bdb-0.5.4/src -I/opt/ts/local/db4.3.21/include -c lock.c
gcc -g -O2 -I. -I../../.. -I../../../. -I../../.././ext/bdb-0.5.4/src -I/opt/ts/local/db4.3.21/include -c delegator.c
gcc -g -O2 -I. -I../../.. -I../../../. -I../../.././ext/bdb-0.5.4/src -I/opt/ts/local/db4.3.21/include -c sequence.c
gcc -g -O2 -I. -I../../.. -I../../../. -I../../.././ext/bdb-0.5.4/src -I/opt/ts/local/db4.3.21/include -c recnum.c
ar cru bdb.a bdb.o env.o log.o transaction.o cursor.o common.o lock.o delegator.o sequence.o recnum.o
make[1]: Leaving directory `/opt/ts/ruby/tmp/ruby-1.8.2/ext/bdb-0.5.4/src'

[...]

make[1]: Entering directory `/opt/ts/ruby/tmp/ruby-1.8.2'
gcc -g -O2 -I. -I. -o ext/extinit.o -c ext/extinit.c
gcc -g -O2 -rdynamic -Wl,-export-dynamic -L. -L'/opt/ts/local/db4.3.21/lib' -Wl,-R'/opt/ts/local/db4.3.21/lib' main.o ext/extinit.o ext/bdb-0.5.4/src/bdb.a -lruby-static -ldl -lcrypt -lm -ldb-4.3 -o ruby
make[1]: Leaving directory `/opt/ts/ruby/tmp/ruby-1.8.2'
uln%

uln% ./ruby -e 'p BDB::VERSION'
"Sleepycat Software: Berkeley DB 4.3.21: (November 8, 2004)"
uln%



Guy Decoux


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
installing a ruby gem with a native extension aj Ruby 7 04-30-2010 11:59 PM
writing native ObjC extension to ruby ?? Yvon Thoraval Ruby 10 08-08-2006 08:12 AM
Compiling a Ruby extension Axel Ruby 3 09-01-2005 01:08 PM
Compiling when libedit is in path Is there a trick to compiling Ruby when libedit must exist in the search path? Can you statically link to readline 5.0 in some manner? -- Lon Baker Lon Baker Ruby 1 03-21-2005 08:57 AM
ruby-mysql native extension for mswin32 Sarah Tanembaum Ruby 1 12-19-2004 09:55 PM



Advertisments