Re: Ruby extension issue

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 S.
Bachelor Computer Science, University Ghent

http://nanoblog.ath.cx
My weblog, powered by Ruby and BSD licensed.

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

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 H. - [email protected] - http://blog.segment7.net

I LIT YOUR GEM ON FIRE!

Eric H. wrote:

create_makefile(‘gamer’)
checking for SDL_Init() in -lSDL… no

Ok thanks :slight_smile: Could you also explain what these methods do exactly?

Wim


Wim Vander S.
Bachelor Computer Science, University Ghent

http://nanoblog.ath.cx
My weblog, powered by Ruby and BSD licensed.

On Dec 28, 2006, at 14:39, Wim Vander S. wrote:

documentation about

Ok thanks :slight_smile: 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 H. - [email protected] - http://blog.segment7.net

I LIT YOUR GEM ON FIRE!

On Fri, 2006-12-29 at 18:13 +0900, Wim Vander S. wrote:

Thank you, but my main problem is the pkg_config :frowning:

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

Eric H. wrote:

Any help would be appreciated, since there seems to be no
libraries and headers can’t be found.

pkg_config(“sdl”)

Thank you, but my main problem is the pkg_config :frowning:
Well for now I’ll just be happy that it works :slight_smile:

Wim


Wim Vander S.
Bachelor Computer Science, University Ghent

http://nanoblog.ath.cx
My weblog, powered by Ruby and BSD licensed.