2022.1 に書いたメモが出てきたのでpublishしておく。
これわかりやすい。iStastsの作者が、そのgemを例に出して説明してくれている。
C code and Makefile
As mentioned previously, the C code is located under the ext directory. Each C module should have its own subdirectory in there. Note that this directory also contains another important file named extconf.rb. The content of this file is executed when installing the gem to generate a Makefile that will be used to compile the C extension. Here’s a basic example:
に従って、 https://github.com/kudojp/ruby-c-extension-experimental で実際にc-extensionをrubyから動かした。非常にシンプル!