[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Re: Ruby extension issue

Wim Vander Schelden

12/28/2006 9:46:00 PM

I was able to fix the problem by changing my extconf.rb to:

require 'mkmf'

dir_config('gamer')
have_library("SDL", "SDL_Init")
have_header("SDL/SDL.h")
pkg_config("sdl")
create_makefile('gamer')

However, I don't know *WHY* it works. The pkg_config seems to be the
crucial line.
I just went through other people's extconf.rb files and guessed the
"sdl" value.
Any help would be appreciated, since there seems to be no documentation
about
pkg_config...

Wim

--
Wim Vander Schelden
Bachelor Computer Science, University Ghent

http://nanob...
My weblog, powered by Ruby and BSD licensed.


5 Answers

Eric Hodel

12/28/2006 10:36:00 PM

0

On Dec 28, 2006, at 13:45, Wim Vander Schelden wrote:

> I was able to fix the problem by changing my extconf.rb to:
>
> require 'mkmf'
>
> dir_config('gamer')
> have_library("SDL", "SDL_Init")
> have_header("SDL/SDL.h")
> pkg_config("sdl")
> create_makefile('gamer')
>
> However, I don't know *WHY* it works. The pkg_config seems to be
> the crucial line.
> I just went through other people's extconf.rb files and guessed the
> "sdl" value.
> Any help would be appreciated, since there seems to be no
> documentation about
> pkg_config...

$ ruby extconf.rb
checking for SDL_Init() in -lSDL... no
checking for SDL/SDL.h... no
creating Makefile
$

You should never call create_makefile makefile when required
libraries and headers can't be found.

--
Eric Hodel - drbrain@segment7.net - http://blog.se...

I LIT YOUR GEM ON FIRE!


Wim Vander Schelden

12/28/2006 10:40:00 PM

0

Eric Hodel wrote:
> On Dec 28, 2006, at 13:45, Wim Vander Schelden wrote:
>
>> I was able to fix the problem by changing my extconf.rb to:
>>
>> require 'mkmf'
>>
>> dir_config('gamer')
>> have_library("SDL", "SDL_Init")
>> have_header("SDL/SDL.h")
>> pkg_config("sdl")
>> create_makefile('gamer')
>>
>> However, I don't know *WHY* it works. The pkg_config seems to be the
>> crucial line.
>> I just went through other people's extconf.rb files and guessed the
>> "sdl" value.
>> Any help would be appreciated, since there seems to be no
>> documentation about
>> pkg_config...
>
> $ ruby extconf.rb
> checking for SDL_Init() in -lSDL... no
> checking for SDL/SDL.h... no
> creating Makefile
> $
>
> You should never call create_makefile makefile when required libraries
> and headers can't be found.
>
> --Eric Hodel - drbrain@segment7.net - http://blog.se...
>
> I LIT YOUR GEM ON FIRE!
>
>
>
Ok thanks :) Could you also explain what these methods do exactly?

Wim

--
Wim Vander Schelden
Bachelor Computer Science, University Ghent

http://nanob...
My weblog, powered by Ruby and BSD licensed.


Eric Hodel

12/28/2006 11:42:00 PM

0

On Dec 28, 2006, at 14:39, Wim Vander Schelden wrote:
> Eric Hodel wrote:
>> On Dec 28, 2006, at 13:45, Wim Vander Schelden wrote:
>>
>>> I was able to fix the problem by changing my extconf.rb to:
>>>
>>> However, I don't know *WHY* it works. The pkg_config seems to be
>>> the crucial line.
>>> I just went through other people's extconf.rb files and guessed
>>> the "sdl" value.
>>> Any help would be appreciated, since there seems to be no
>>> documentation about
>>> pkg_config...
>>
>> $ ruby extconf.rb
>> checking for SDL_Init() in -lSDL... no
>> checking for SDL/SDL.h... no
>> creating Makefile
>> $
>>
>> You should never call create_makefile makefile when required
>> libraries and headers can't be found.
>
> Ok thanks :) Could you also explain what these methods do exactly?

> require 'mkmf'
>
> dir_config('gamer')

dunno

> have_library("SDL", "SDL_Init")

Do we have an SDL_Init() declared in libSDL.so (platform dependent)?
Returns true or false if it was found or not. Check the return
value and abort if false and you need this library.

> have_header("SDL/SDL.h")

Do we have an SDL/SDL.h file lying around somewhere? Returns true or
false if it was found or not. Check the return value and abort if
false and you need this library.

> pkg_config("sdl")

dunno

> create_makefile('gamer')

creates a Makefile that will build gamer.so

--
Eric Hodel - drbrain@segment7.net - http://blog.se...

I LIT YOUR GEM ON FIRE!


Wim Vander Schelden

12/29/2006 9:14:00 AM

0

Eric Hodel wrote:
> On Dec 28, 2006, at 14:39, Wim Vander Schelden wrote:
>> Eric Hodel wrote:
>>> On Dec 28, 2006, at 13:45, Wim Vander Schelden wrote:
>>>
>>>> I was able to fix the problem by changing my extconf.rb to:
>>>>
>>>> However, I don't know *WHY* it works. The pkg_config seems to be
>>>> the crucial line.
>>>> I just went through other people's extconf.rb files and guessed the
>>>> "sdl" value.
>>>> Any help would be appreciated, since there seems to be no
>>>> documentation about
>>>> pkg_config...
>>>
>>> $ ruby extconf.rb
>>> checking for SDL_Init() in -lSDL... no
>>> checking for SDL/SDL.h... no
>>> creating Makefile
>>> $
>>>
>>> You should never call create_makefile makefile when required
>>> libraries and headers can't be found.
>>
>> Ok thanks :) Could you also explain what these methods do exactly?
>
>> require 'mkmf'
>>
>> dir_config('gamer')
>
> dunno
>
>> have_library("SDL", "SDL_Init")
>
> Do we have an SDL_Init() declared in libSDL.so (platform dependent)?
> Returns true or false if it was found or not. Check the return value
> and abort if false and you need this library.
>
>> have_header("SDL/SDL.h")
>
> Do we have an SDL/SDL.h file lying around somewhere? Returns true or
> false if it was found or not. Check the return value and abort if
> false and you need this library.
>
>> pkg_config("sdl")
>
> dunno
>
>> create_makefile('gamer')
>
> creates a Makefile that will build gamer.so
>
> --Eric Hodel - drbrain@segment7.net - http://blog.se...
>
> I LIT YOUR GEM ON FIRE!
>
>
>
Thank you, but my main problem is the pkg_config :-(
Well for now I'll just be happy that it works :-)

Wim

--
Wim Vander Schelden
Bachelor Computer Science, University Ghent

http://nanob...
My weblog, powered by Ruby and BSD licensed.


Tom Copeland

12/29/2006 2:34:00 PM

0

On Fri, 2006-12-29 at 18:13 +0900, Wim Vander Schelden wrote:
> Thank you, but my main problem is the pkg_config :-(

pkg_config calls the Gnome utility pkg-config to get information about
the libraries that are installed. For example:

$ pkg-config --libs libebook-1.2
-pthread -L/lib -lebook-1.2 -lgnome-2 -lpopt -ledataserver-1.2
-lgnomevfs-2 -lgobject-2.0 -lxml2 -lz -lgconf-2 -lbonobo-2
-lbonobo-activation -lORBit-2 -lm -lgmodule-2.0 -ldl -lgthread-2.0
-lglib-2.0

The nice thing about using the extconf.rb pkg_config method is that you
don't have to explicitly list all of those libraries to compile/link
your extension.

One thing that confused me at first was that the extconf.rb method is
"pkg_config" (with an underscore) and the Gnome utility program is
"pkg-config" (with a dash). But anyhow, it's very handy and it can make
your extconf.rb files much shorter.

Yours,

Tom