OpenGL and Ruby?

Discussion in 'Ruby' started by anne001, Jan 15, 2006.

  1. anne001

    anne001 Guest

    I would like to learn a little computer graphics. Courses I have looked
    at don't teach maya, zbrush etc, they teach computer programming with

    Can I use OpenGL with Ruby? Do I need to install anything extra (OX
    Tiger with ruby1.8).

    If I do need to install OpenGL, is this advice safe to follow on Tiger?

    How can I go about learning OpenGL and Ruby at the same time? (I have
    written a small program in Ruby, I am learning methods, object
    structure etc). Is there any documentation on how to use OpenGL from
    anne001, Jan 15, 2006
    1. Advertisements

  2. anne001

    anne001 Guest

    I tried to install openGL for ruby, opengl-0.32f and opengl-0.32g

    Ruby-OpenGL Bindings for Mac OS X
    $ ruby extconf.rb

    I get an error
    can't find header files for ruby. I found a reference which suggests it
    is not finding ruby.h?
    How do I find ruby.h, and when I find it, what do I do next?
    anne001, Jan 15, 2006
    1. Advertisements

  3. anne001

    anne001 Guest

    the first line of extconf.rb is

    require "mkmf", which is also the first line in programming ruby, ed 2
    page 277.

    If I just run that line, I get the same error message,
    require "mkmf"
    can't find header files for ruby.

    I am using the ruby that comes with Tiger.

    I tried the make, and I found a recent mkmf.log file. But I don't think
    the extconf.rb ran all the way, so who knows what make does!

    any suggestion?
    anne001, Jan 15, 2006
  4. Requirements for using opengl are the opengl LIBRARIES (libGL,libGLU,
    and some applications use glut) and the ruby WRAPPER such as
    and HEADERS for ruby.

    You need the headers from one of:
    {first look in the libraries /usr/local/lib/ruby/1.8/i686-linux/ruby.h
    (substitute for i686-linux your arch)
    Ruby should find it if it is there, but you can use a link to it.}
    {If it is not there, and ruby on your system is installed from
    the header files are in a separate package with '-dev' in the name.
    Install that package.}
    {The headers that are required are in the top directory of the ruby
    package. You can link/copy the files from the ruby source for the
    version you are using.}

    Older versions of ruby also used some other files that were provided in

    the top directory of the source package.

    Regarding the 'who knows what make does', there should never be
    a file 'Makefile' in the top directory of a package that contains the
    file 'extconf.rb' The purpose of executing 'ruby extconf.rb' is to
    that requirements have been met on the system. If all conditions are
    then a Makefile is created. If not, there is no Makefile.

    I do not know about special considerations for Tiger.

    There are many examples in the directory 'sample' of the wrapper.

    Best regards
    Gerald Murray, Jan 15, 2006
  5. anne001

    anne001 Guest

    thank you so much for your response.

    I did indeed find ruby.h in

    and I found mkmf.rb in the usr/lib/ruby/1.8 directory.
    I tried to debug mkmf.rb with puts. I found that it was looking for
    ruby.h in

    I jerryrigged it (using sudo to change the file) to look for ruby.h in
    the right directory.

    libdir = "/usr/lib/ruby/1.8"
    $extmk = libdir != Config::CONFIG["rubylibdir"]
    if not $extmk and File.exist?
    $hdrdir = $topdir ="/usr/lib/ruby/1.8/universal-darwin8.0"
    elsif File.exist? $srcdir + "/ruby.h"
    $topdir = Config::CONFIG["compile_dir"]
    $hdrdir = $srcdir
    abort "can't find header files for ruby."

    this took care of the header file error.

    checking for XAllowDeviceEvents() in -lXi... no
    checking for XMITMiscGetBugMode() in -lXext... no
    checking for XmuAddCloseDisplayHook() in -lXmu... no
    checking for XOpenDisplay() in -lX11... no
    checking for main() in -lGL... no
    checking for main() in -lMesaGL... no
    can't create OpenGL module!

    I have to figure out if this is also a path problem or if there are
    files missing.
    According to this site, openGL does come with tiger.
    Mac OS X v10.2 OpenGL CFM Software Development Kit (DMG)
    is from 2003. Do I need that?

    I wish mkmf.rb did not have this bug in the path, so I did not have to
    worry about what it does!
    IS THERE A FIX TO MKMF.RB so it won't have this path problem on the
    1.8.2 that comes pre-installed on Ruby? If so, where do I find it?

    thank you for helping me along

    anne001, Jan 16, 2006
  6. anne001

    anne001 Guest

    oups ignore the previous error messages
    the opengl-0.32g folder
    does not come with darwin option in the extconf.rb

    when I ran the extconf.rb which came with opengl-0.32f modified for
    2005-04-26 :: James Adam <>
    I get the following error.

    ruby extconf.rb
    checking for main() in -lGL... no
    checking for main() in -lMesaGL... no
    checking for main() in -lGL... no
    can't create OpenGL module!
    I did check that opengl frameworks and glut frameworks are in the

    again, there seems to be a disconnect, it is looking for lGl when I
    have libGL
    system/library/frameworks/OpenGL.framework/Libraries anne$ ls
    libGL.dylib libGLSystem.dylib
    libGLImage.dylib libGLU.dylib

    It seems like the program is looking for a main function in a GL
    library. I tried this
    puts find_library("ibGL.dylib", func,
    and get
    checking for main() in -libGL.dylib... no
    tried without the extension
    checking for main() in -libGL... no
    tried with the whole name
    checking for main() in -llibGL... no

    It seems to me the problem is with finding an appropriate extconf.rb to
    install the opengl-0.32g onto my Tiger system!
    did not work, it was for panther.
    Makefile.glut:40: *** missing separator. Stop.
    make: *** [glut.bundle] Error 2

    but I only found these two extconf, and obviously something is off.
    Hope someone out there knows what to do!
    anne001, Jan 16, 2006
  7. on unix, the
    checking for ? in -lX11
    means it is trying to test that function using a test program for the
    The library may be present, but has no symbols (and headers were not
    found.) OR the test program did not find the path to the library.
    So either correct the path, or add the header files, usually found in a
    package with the same name, but containing '-dev' in its name.

    the test for symbols is to use the nm command
    nm /usr/lib/

    Gerald Murray, Jan 16, 2006
  8. anne001

    anne001 Guest

    Thank you for your suggestion. I only saw it now

    I followed the instructions on
    without any understanding, but just as indicated

    1. I kept the beginning of this line
    CFLAGS = -fno-common -arch i386 -arch ppc -g -Os -pipe
    2. I replaced powerpc-darwin8.0 to universal-darwin8.0 in the ruby

    I got a few warning messages
    Now Making glut extend module
    gcc -fno-common -arch i386 -arch ppc -g -Os -pipe
    -I/System/Library/Frameworks/GLUT.framework/Headers -I.
    -I/usr/lib/ruby/1.8/universal-darwin8.0 -I. -I. -c glut.c
    glut.c: In function 'glut_KeyboardFunc':
    glut.c:147: warning: passing argument 1 of 'glutKeyboardFunc' from
    incompatible pointer type
    glut.c: In function 'glut_KeyboardFunc':
    glut.c:147: warning: passing argument 1 of 'glutKeyboardFunc' from
    incompatible pointer type
    cc -dynamic -bundle -undefined suppress -flat_namespace
    -L/usr/lib/ruby/1.8/universal-darwin8.0 -L/usr/lib
    -L/System/Library/Frameworks/OpenGL.framework/Libraries -L"/usr/lib" -o
    glut.bundle glut.o -ldl -lruby -lGLU -lGL -lobjc -framework GLUT
    Now Making opengl extend module
    cc -dynamic -bundle -undefined suppress -flat_namespace
    -L/usr/lib/ruby/1.8/universal-darwin8.0 -L/usr/lib
    -L/System/Library/Frameworks/OpenGL.framework/Libraries -L"/usr/lib" -o
    opengl.bundle glu.o ogl.o rbogl.o -ldl -lruby -lGLU -lGL -lobjc
    -framework GLUT

    robot.rb works with the letter e and s (esc (ascii code 27)) to stop

    then I ran sudo make install

    I don't know what I have achieved, but since ruby sample/robot.rb
    I should be able to do something with opengl?

    I hope this is correct, and that it helps someone else!
    anne001, Jan 16, 2006
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.