Forum: Ruby Re: Ruby extension issue

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ae9705d43819ffe40a6936aeaf71205b?d=identicon&s=25 Wim Vander Schelden (Guest)
on 2006-12-28 22:47
(Received via mailing list)
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://nanoblog.ath.cx
My weblog, powered by Ruby and BSD licensed.
58479f76374a3ba3c69b9804163f39f4?d=identicon&s=25 Eric Hodel (Guest)
on 2006-12-28 23:37
(Received via mailing list)
On Dec 28, 2006, at 13:45, Wim Vander Schelden 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 Hodel - drbrain@segment7.net - http://blog.segment7.net

I LIT YOUR GEM ON FIRE!
Ae9705d43819ffe40a6936aeaf71205b?d=identicon&s=25 Wim Vander Schelden (Guest)
on 2006-12-28 23:39
(Received via mailing list)
Eric Hodel 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 Schelden
Bachelor Computer Science, University Ghent

http://nanoblog.ath.cx
My weblog, powered by Ruby and BSD licensed.
58479f76374a3ba3c69b9804163f39f4?d=identicon&s=25 Eric Hodel (Guest)
on 2006-12-29 00:44
(Received via mailing list)
On Dec 28, 2006, at 14:39, Wim Vander Schelden 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 Hodel - drbrain@segment7.net - http://blog.segment7.net

I LIT YOUR GEM ON FIRE!
Ae9705d43819ffe40a6936aeaf71205b?d=identicon&s=25 Wim Vander Schelden (Guest)
on 2006-12-29 10:15
(Received via mailing list)
Eric Hodel 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 Schelden
Bachelor Computer Science, University Ghent

http://nanoblog.ath.cx
My weblog, powered by Ruby and BSD licensed.
560c83ff6b6600e39315a1cf75b7c229?d=identicon&s=25 Tom Copeland (Guest)
on 2006-12-29 15:34
(Received via mailing list)
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
This topic is locked and can not be replied to.