# Re: Ruby extension issue

**URL:** <https://www.ruby-forum.com/t/re-ruby-extension-issue/80586>\
**Category:** Ruby\
**Created:** [December 28, 2006, 10:47pm UTC](https://www.ruby-forum.com/t/re-ruby-extension-issue/80586 "2006-12-28T22:47:52Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wim\_Vander\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/13edae/32.png) [@Wim\_Vander\_S](https://www.ruby-forum.com/u/Wim_Vander_S)\
**Post date:** [December 28, 2006, 10:47pm UTC](https://www.ruby-forum.com/t/re-ruby-extension-issue/80586/1 "2006-12-28T22:47:52Z")

</div>

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](http://nanoblog.ath.cx)  
My weblog, powered by Ruby and BSD licensed.

---

<div class="post-metadata">

**Author:** ![Wim\_Vander\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/13edae/32.png) [@Wim\_Vander\_S](https://www.ruby-forum.com/u/Wim_Vander_S)\
**Post date:** [December 28, 2006, 11:37pm UTC](https://www.ruby-forum.com/t/re-ruby-extension-issue/80586/2 "2006-12-28T23:37:57Z")

</div>

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. - removed\_email\_address@domain.invalid - [http://blog.segment7.net](http://blog.segment7.net)

I LIT YOUR GEM ON FIRE!

---

<div class="post-metadata">

**Author:** ![Wim\_Vander\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/13edae/32.png) [@Wim\_Vander\_S](https://www.ruby-forum.com/u/Wim_Vander_S)\
**Post date:** [December 28, 2006, 11:39pm UTC](https://www.ruby-forum.com/t/re-ruby-extension-issue/80586/3 "2006-12-28T23:39:57Z")

</div>

Eric H. wrote:

> > create\_makefile(‘gamer’)  
> > checking for SDL\_Init() in -lSDL… no

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

Wim

–  
Wim Vander S.  
Bachelor Computer Science, University Ghent

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

---

<div class="post-metadata">

**Author:** ![Wim\_Vander\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/13edae/32.png) [@Wim\_Vander\_S](https://www.ruby-forum.com/u/Wim_Vander_S)\
**Post date:** [December 29, 2006, 12:44am UTC](https://www.ruby-forum.com/t/re-ruby-extension-issue/80586/4 "2006-12-29T00:44:05Z")

</div>

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

> > > documentation about
> 
> 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 H. - removed\_email\_address@domain.invalid - [http://blog.segment7.net](http://blog.segment7.net)

I LIT YOUR GEM ON FIRE!

---

<div class="post-metadata">

**Author:** ![Wim\_Vander\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/13edae/32.png) [@Wim\_Vander\_S](https://www.ruby-forum.com/u/Wim_Vander_S)\
**Post date:** [December 29, 2006, 3:34pm UTC](https://www.ruby-forum.com/t/re-ruby-extension-issue/80586/5 "2006-12-29T15:34:14Z")

</div>

On Fri, 2006-12-29 at 18:13 +0900, Wim Vander S. 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

---

<div class="post-metadata">

**Author:** ![Wim\_Vander\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/13edae/32.png) [@Wim\_Vander\_S](https://www.ruby-forum.com/u/Wim_Vander_S)\
**Post date:** [December 29, 2006, 10:15am UTC](https://www.ruby-forum.com/t/re-ruby-extension-issue/80586/6 "2006-12-29T10:15:17Z")

</div>

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 ☹  
Well for now I’ll just be happy that it works 🙂

Wim

–  
Wim Vander S.  
Bachelor Computer Science, University Ghent

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