Mkmf and extconf.rb


(Ian Macdonald) #1

Hi,

I’m using the mkmf module to create a Makefile for a C extension I’m
writing. Unfortunately, when I create the Makefile using
’create_makefile(‘foo’)’ in extconf.rb, the following line gets
written out:

LIBS = -L. -l$(RUBY_INSTALL_NAME) -lc

This has the effect that my tiny piece of code is linked against
libruby, which has the effect of making it unnecessarily huge. How can
I stop mkmf from adding ‘-l$(RUBY_INSTALL_NAME)’ to LIBS?

Ian

···


Ian Macdonald | The co-locator cannot verify the
ian@caliban.org | frame-relay gateway to the ISDN server.
>
>
>


(Ian Macdonald) #2

I’ve managed to figure this out. libruby.a was getting linked in by
accident.

Ian

···

On Wed 19 Jun 2002 at 07:40:34 +0900, Ian Macdonald wrote:

I’m using the mkmf module to create a Makefile for a C extension I’m
writing. Unfortunately, when I create the Makefile using
’create_makefile(‘foo’)’ in extconf.rb, the following line gets
written out:

LIBS = -L. -l$(RUBY_INSTALL_NAME) -lc

This has the effect that my tiny piece of code is linked against
libruby, which has the effect of making it unnecessarily huge. How can
I stop mkmf from adding ‘-l$(RUBY_INSTALL_NAME)’ to LIBS?


Ian Macdonald | “If you understand what you’re doing,
ian@caliban.org | you’re not learning anything.” – A. L.
>
>
>


(Lyle Johnson) #3

I’m using the mkmf module to create a Makefile for a C extension I’m
writing. Unfortunately, when I create the Makefile using
’create_makefile(‘foo’)’ in extconf.rb, the following line gets
written out:

LIBS = -L. -l$(RUBY_INSTALL_NAME) -lc

This has the effect that my tiny piece of code is linked against
libruby, which has the effect of making it unnecessarily huge. How can
I stop mkmf from adding ‘-l$(RUBY_INSTALL_NAME)’ to LIBS?

Well, you have to link your extension against the Ruby library so that it
can resolve your calls to functions like rb_define_method() et al. But I
would guess that you’re linking against the static library (libruby.a)
instead of the shared library (libruby.so)? If so you need to go back and
configure the Ruby build to use a shared library instead, i.e.

./configure --enable-shared
make
make install

Hope this helps,

Lyle