[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Problem writting bindings

Erwan Loisant

10/22/2004 3:49:00 PM

Hello.

I am writing Ruby bindings for a C library that I wrote myself. I have
a problem when running extconf.

My library uses glib so I added glib also.

----
erwan@bourricot Galois $ cat extconf.rb
require 'mkmf'

dir_config('libGalois')
dir_config('glib')

have_library('glib')
have_library('libGalois')

create_makefile('GaloisNode')
----

Then I launch extconf.rb:

----
erwan@bourricot Galois $ ruby extconf.rb
--with-libGalois-dir=/usr/local/
checking for main() in -lglib... yes
checking for main() in -llibGalois... no
creating Makefile
----

The problem is in the generated Makefile, "-lglib" is added but not
"-llibGalois". I guess the "checking for main() in -llibGalois... no"
is the error message related to the problem but I can't figure what it
means. A library is not supposed to have main() loop, right?

4 Answers

ts

10/22/2004 4:04:00 PM

0

>>>>> "E" == Erwan Loisant <eloisant@gmail.com> writes:

E> checking for main() in -llibGalois... no

You must give him a symbol which is exported, for example bz2 has

svg% ruby -rmkmf -e 'p have_library("bz2", "BZ2_bzWriteOpen")'
checking for BZ2_bzWriteOpen() in -lbz2... yes
true
svg%

svg% nm /usr/lib/libbz2.so | grep BZ2_bzWriteOpen
0000bc20 T BZ2_bzWriteOpen
svg%



Guy Decoux


Paul Duncan

10/22/2004 4:05:00 PM

0

* Erwan Loisant (eloisant@gmail.com) wrote:
> Hello.
>
> I am writing Ruby bindings for a C library that I wrote myself. I have
> a problem when running extconf.
>
> My library uses glib so I added glib also.
>
> ----
> erwan@bourricot Galois $ cat extconf.rb
> require 'mkmf'
>
> dir_config('libGalois')
> dir_config('glib')
>
> have_library('glib')
> have_library('libGalois')
>
> create_makefile('GaloisNode')
> ----
>
> Then I launch extconf.rb:
>
> ----
> erwan@bourricot Galois $ ruby extconf.rb
> --with-libGalois-dir=/usr/local/
> checking for main() in -lglib... yes
> checking for main() in -llibGalois... no
> creating Makefile
> ----
>
> The problem is in the generated Makefile, "-lglib" is added but not
> "-llibGalois". I guess the "checking for main() in -llibGalois... no"
> is the error message related to the problem but I can't figure what it
> means. A library is not supposed to have main() loop, right?

You should pass a function in the library to the have_library method,
like this:

have_library('glib', 'g_timer_start')

My guess is you'll want the other have_library call to look like this:

have_library('Galois', 'func_name') # note the omitted 'lib' prefix

Hope that helps...

--
Paul Duncan <pabs@pablotron.org> pabs in #ruby-lang (OPN IRC)
http://www.pabl... OpenPGP Key ID: 0x82C29562

nobu.nokada

10/22/2004 4:06:00 PM

0

Hi,

At Sat, 23 Oct 2004 00:54:13 +0900,
Erwan Loisant wrote in [ruby-talk:117376]:
> erwan@bourricot Galois $ cat extconf.rb
> require 'mkmf'
>
> dir_config('libGalois')
> dir_config('glib')
>
> have_library('glib')
> have_library('libGalois')

have_library('Galois')

"lib" prefix is automatically prepended.

--
Nobu Nakada


Erwan Loisant

10/22/2004 4:54:00 PM

0

Thank you to all of you! It works now.