Skip to content

Compiling on Linux

Chadow edited this page Nov 14, 2023 · 10 revisions

Contents

  1. Building Gosu
  2. Building MRuby
  3. Building The Wrapper
  4. Distributing

Building Gosu

Requirements

See.

Building

Get the source code from the releases page then extract it on some place, make sure the directory is named gosu after the extraction. Create a directory named build/, cd to it and:

cmake ..
make

Then move the generated libgosu.so and ffi/libgosu-ffi.so to lib64/

Building MRuby

Get the source code from the tags page, extract it on the same directory where the gosu folder from the previous step is, in a way that the directory structure will be like this:

.
├── gosu
|   ├── ffi
|   |   └── headers needed for compilation
│   └── lib64
│       ├── libgosu.so
│       └── libgosu-ffi.so
└── mruby

You can use the following MRuby configuration:

MRuby::Build.new do |conf|
  conf.toolchain :gcc

  conf.gembox 'default'

  conf.gem github: 'chadowo/mruby-gosu'
  conf.gem github: 'mattn/mruby-require' # Add require and load functionality to MRuby

  # C compiler settings
  conf.cc.defines = %w(MRB_USE_DEBUG_HOOK MRB_INT64)
  conf.cc.flags << '-fpermissive' # Needed for mruby-require

  conf.enable_debug
  conf.enable_cxx_abi
end

Save it as gosu.rb in the MRuby build_config directory, then we use the MRUBY_COFIG environment variable to select our configuration:

MRUBY_CONFIG=gosu rake

Remember to run it on the root MRuby directory. As the compilation finalizes, you'll get the libmruby.a file, in the build/host/lib/ directory.

Building The Wrapper

Get the source code from releases page and extract it, on the vendor directory, under mruby/ put libmruby.a, and create another directory there named gosu, as you guessed, the .so files we built earlier will go there. then proceed to create the build directory in the source code directory, and cd to it, then do the following:

cmake ..
make

And that's it!

Distributing

Since we can't expect every person to ever run the compiled binary to have Gosu installed on their system, we'll need to bundle the .so files with the binary, so just grab them from the vendor/gosu directory and put them with your binary. Simple as that.

Clone this wiki locally