All original content is created in Ukrainian. Not all content has been translated yet. Some posts may only be available in Ukrainian.Learn more

[Fix] extconf.rb failed during the installation of the Ruby library Gosu

Post cover: [Fix] extconf.rb failed during the installation of the Ruby library Gosu
This content has been automatically translated from Ukrainian.
Gosu is a popular gem for Ruby that provides a simple and powerful interface for creating 2D games. It includes features for working with graphics, sound, and input (controls).
While trying to install the Gosu library, I received the following error:
~ gem install gosu
Building native extensions. This could take a while...
ERROR:  Error installing gosu:
ERROR: Failed to build gem native extension.

    current directory: /Users/user/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/gosu-1.4.6/ext/gosu
/Users/user/.rbenv/versions/3.2.1/bin/ruby extconf.rb
The Gosu gem requires some libraries to be installed system-wide.
See the following site for a list:
https://github.com/gosu/gosu/wiki/Getting-Started-on-OS-X
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/user/.rbenv/versions/3.2.1/bin/$(RUBY_BASE_NAME)
extconf.rb:71:in ``': No such file or directory - sdl2-config (Errno::ENOENT)
from extconf.rb:71:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in /Users/user/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/gosu-1.4.6 for inspection.
Results logged to /Users/nikita/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/extensions/x86_64-darwin-23/3.2.0/gosu-1.4.6/gem_make.out
The machine is a Mac with M1, but the terminal is running under Rosseta.
Checking:
~ arch
i386
Brew is already installed, so I need to install the libraries required by Gosu, namely:
brew install sdl2
brew install sdl2_image
brew install sdl2_mixer
brew install sdl2_ttf
brew install libogg
brew install libvorbis
After that, gosu and gosu-examples install without any issues:
~ gem install gosu 
Building native extensions. This could take a while...
Successfully installed gosu-1.4.6
Parsing documentation for gosu-1.4.6
Installing ri documentation for gosu-1.4.6
Done installing documentation for gosu after 0 seconds
1 gem installed
~ gem install gosu-examples

Successfully installed gosu-examples-1.0.7
Parsing documentation for gosu-examples-1.0.7
Installing ri documentation for gosu-examples-1.0.7
Done installing documentation for gosu-examples after 0 seconds
1 gem installed
Running gosu-examples to see the window with game examples.
~ gosu-examples
*** Cannot load chipmunk_and_rmagick.rb:
cannot load such file -- chipmunk

*** Cannot load chipmunk_integration.rb:
cannot load such file -- chipmunk

*** Cannot load opengl_integration.rb:
cannot load such file -- opengl

*** Cannot load rmagick_integration.rb:
cannot load such file -- rmagick
gosu-examples
gosu-examples
These warnings in the terminal (cannot load such file) I will fix later (if needed, of course).
Like it?React
🧵

This post doesn't have any additions from the author yet.

May 9, '25 19:27

[FIXED] cannot load such file -- html/pipeline (LoadError) occurs during rails generate thredded:install

Jun 5, '25 01:52

[Fixed] uninitialized constant ActiveSupport::LoggerThreadSafeLevel::Logger (NameError)

May 9, '24 12:43

[Fix] Rails Admin - undefined local variable or method javascript_importmap_shim_nonce_configuration_tag

Jan 3, '24 13:16

Fixing An error occurred while installing tiny_tds (2.1.5), and Bundler cannot continue on Mac with M1

[Fix] Factory not registered: "user" (KeyError) (FactoryBot / Rails 7)
Dec 7, '24 10:46

[Fix] Factory not registered: "user" (KeyError) (FactoryBot / Rails 7)

What is a function in programming?
Jun 24, '24 18:15

What is a function in programming?

What is the difference between variables that start with @, @@, and $?
Jun 23, '24 14:00

What is the difference between variables that start with @, @@, and $?

How to make an empty git commit?
Jun 28, '24 08:33

How to make an empty git commit?

What will be the result of adding 10.5 and 10?
Jun 23, '24 13:23

What will be the result of adding 10.5 and 10?

Ruby library Gosu for creating 2D games
Jun 29, '24 08:48

Ruby library Gosu for creating 2D games

Gosu Ruby Tutorial - пройдемось по офіційній документації
Jul 3, '24 11:50

Gosu Ruby Tutorial - пройдемось по офіційній документації

We are writing a demo game Drones vs Zombies (Gosu / Ruby)
Jul 12, '24 12:17

We are writing a demo game Drones vs Zombies (Gosu / Ruby)

How to fix a Windows crash caused by CrowdStrike?
Jul 19, '24 13:53

How to fix a Windows crash caused by CrowdStrike?

What is immutability and mutability?
Jun 19, '24 07:48

What is immutability and mutability?

What does the error 'is out of range' mean in Ruby on Rails? Range Error - Integer with limit 4 bytes
Jun 13, '24 07:18

What does the error 'is out of range' mean in Ruby on Rails? Range Error - Integer with limit 4 bytes

What is the difference between int and bigint in Ruby? Minimum and maximum values.
Jun 13, '24 06:37

What is the difference between int and bigint in Ruby? Minimum and maximum values.

What does .map(&:name) mean in Ruby?
Jul 28, '24 11:18

What does .map(&:name) mean in Ruby?