Forum: Ruby Ruby extension issue

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Wim Vander S. (Guest)
on 2006-12-28 23:15
(Received via mailing list)

I am playing around with building ruby extensions in C but I have a
I'm trying to make some bindings to SDL, and everything compiles fine,
but when I load the extension in IRB, I get the following:

    irb(main):001:0> require 'gamer'
    irb: symbol lookup error: ./ undefined symbol: SDL_Init

My C code is:

    #include <stdio.h>
    #include <ruby.h>
    #include <SDL/SDL.h>

    static VALUE rb_mGamer;
    static VALUE rb_cScreen;

    void Init_gamer()
        // Create a Gamer module and a Screen class within it
        rb_mGamer = rb_define_module("Gamer");
        rb_cScreen = rb_define_class_under(rb_mGamer, "Screen",

        // Try and initialize SDL
        Sint32 init_res = SDL_Init(SDL_INIT_EVERYTHING);

        // If not everything went as planned, log the error
        if(init_res < 0)
            if(rb_respond_to(rb_mGamer, rb_intern("log")))
                rb_funcall(rb_mGamer, rb_intern("log"), 1,

        // See what was initialized and set the appropriate flags to
    true or false
        Uint32 winit = SDL_WasInit(SDL_INIT_EVERYTHING);

        if(winit & SDL_INIT_AUDIO)
            rb_define_const(rb_mGamer, "audio", Qfalse);
        } else {
            rb_define_const(rb_mGamer, "audio", Qtrue);

Do I have to tell ruby to load the SDL library as well when loading my

Thanks in advance,


Wim Vander S.
Bachelor Computer Science, University Ghent
My weblog, powered by Ruby and BSD licensed.
This topic is locked and can not be replied to.