Ruby/SDL FAQ

This is FAQ of Ruby/SDL.

Q. I can't use Ruby/SDL on FreeBSD. Why?

I have install Ruby/SDL on FreeBSD, but I just get following message.

/usr/libexec/ld-elf.so.1: /usr/local/lib/libSDL-1.1.so.4: Undefined
symbol "pthread_mutexattr_init"

A. Please use ruby_r

Ruby/SDL needs pthread, so you should use `ruby_r', ruby interpreter linked with pthread library. You will install ruby_r from Ports or Packages Collection. In latest ports, rubysdl uses ruby_r, so you may install from ports.

Q. Can I use thread?

I want to use thread functions of SDL.

A. You can't use SDL's thread. Please use Ruby's thread.

Ruby/SDL can't handle SDL's thread. If you want to use thread, you will use Ruby's thread, or you may redisign your script not to apply threads.

Q. My script doesn't stop normally on Linux.

My script doesn't stop normally when using SDL::Mixer on Linux.

A. Plsease use --disable-pthreads, or trap signals.

According to Lorien Dunn, irregular signal handling occures this problem. You can avoid this problem by two ways. First, when you compile SDL, you should run './configure' with '--disable-pthreads' option, second, put following script first in your program.

require 'rbconfig'

if RUBY_PLATFORM =~ /linux/
  trap('INT','EXIT')
  trap('EXIT','EXIT')
end

if you get the error of `uninitialized constant EXIT (NameError)', you should use following script alternatively,

require 'rbconfig'

if RUBY_PLATFORM =~ /linux/
  trap('EXIT','DEFAULT')
end

Q. I can't use Ruby/SDL on MacOSX.

I can't use Ruby/SDL on MacOSX.

A. You should initialize Cocoa.

Accoring to NUNOKAWA, SDL needs to initialize Cocoa, before calling SDL_Init. And he have found a solution, please see <URL:http://www2s.biglobe.ne.jp/~nunokawa/wiki.cgi?page=Ruby%2FSDL+on+Mac+OS+X> or <URL:http://www.kumaryu.net/?(Ruby)+Ruby%2FSDL%CD%D1ruby> in detail. (this document is written in Japanese)