Skip to content
Chris Gahan edited this page Jan 26, 2016 · 10 revisions

What's mrbgems?

mrbgems is a library manager for mruby.

It is like RubyGems for CRuby, but while RubyGems is dynamic, mrbgems is static. mrbgems is used during building mruby, unlike RubyGems, which is used after ruby is installed.

In detail, see https://github.com/mruby/mruby/blob/master/doc/guides/mrbgems.md

How to add mrbgems?

In mrubys root directory there is a file called build_config.rb that file is where you have your build information. Including the gems you want to add as well as additional information such as included header files and libraries to be linked if your creating your gem with C extensions. Inside the build_config.rb You can add this code in to add in your gems.

conf.gem 'path/to/gem'

If you want to include an include path you do it by writing the code below in your gem specification inside your projects mrbgem.rake file.

conf.cc do |cc|
  cc.include_paths = ''
end

Or you may run into a problem where the mruby.h can't be found in that case do this.

conf.cc do |cc|
  cc.include_paths = ['path/to/mruby/include', 'path/to/your/include']
end

Now if you want to link files you do so like this.

spec.linker do |linker|
   linker.library_paths = 'path/to/lib'
   linker.libraries = ['mingw32', 'foo', 'bar']
 end

Help! My mruby don't have...

Kernel#sleep

See https://github.com/matsumoto-r/mruby-sleep

Random class

See https://github.com/matsumoto-r/mruby-random