Building binary outside of OpenWrt?

I want to use hidapi Ruby gem in my OpenWrt router. While I can install Ruby and utils, I can't install gem.

Commands I use to install Ruby:

opkg update
opkg install ruby
opkg install ruby-gems # or ruby-gem?
opkg install ruby-did-you-mean # for "gem install"
opkg install ruby-enc-extra # for "gem install"
opkg install ruby-dev
opkg install make

Then I'm trying to

gem install hidapi

It says:

Building native extensions. This could take a while...
ERROR:  Error installing hidapi:
	ERROR: Failed to build gem native extension.

    current directory: /usr/lib/ruby/gems/3.0/gems/ffi-1.15.5/ext/ffi_c
/usr/bin/ruby -I /usr/lib/ruby/3.0 -r ./siteconf20220716-5296-z397ow.rb extconf.rb
<internal:/usr/lib/ruby/3.0/rubygems/core_ext/kernel_require.rb>:85:in `require': cannot load such file -- mkmf (LoadError)
	from <internal:/usr/lib/ruby/3.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from extconf.rb:4:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in /usr/lib/ruby/gems/3.0/gems/ffi-1.15.5 for inspection.
Results logged to /usr/lib/ruby/gems/3.0/extensions/arm-linux/3.0/ffi-1.15.5/gem_make.out

On Ubuntu I'd install build-essential(s), but on OpenWrt there is no such option. It seems it's not possible to build something inside the router.

I imagine one can create a docker container, for example, with exactly the same system. But I'm not sure. Really need pointers on how to build something. I need this gem to work with external USB device.

Here is uname -a output (it's OpenWrt custom-flavored firmware):

Linux PrivateRouter 5.4.188 #0 SMP Sat Apr 16 12:59:34 2022 armv7l GNU/Linux

Isn't the same as https://github.com/openwrt/packages/blob/openwrt-21.02/libs/hidapi/Makefile ?

Yeah package is already available and for basically all architectures

Upgrade to 21.02 and install from opkg

This Ruby gem still wants to build something. I tried to install gcc, but I don't have enough space. Wondering if I can build it outside.

Yeah you need a makefile like the one for main ruby https://openwrt.org/docs/guide-developer/packages