LoginSignup
3
6

More than 5 years have passed since last update.

C++のコードをswigでgem化して利用するまでのコマンドまとめ

Last updated at Posted at 2015-05-04

自分用メモ

参考にしたもの
https://github.com/mechamogera/MyTips/wiki/%E6%8B%A1%E5%BC%B5%E3%83%A9%E3%82%A4%E3%83%96%E3%83%A9%E3%83%AA%E3%82%92gem%E5%8C%96%E3%81%97%E3%81%A6%E3%81%BF%E3%82%8B
https://www.gfd-dennou.org/arch/ruby/tutorial/swig/swig-cpp.html

bundle gem example # gemのひな形作成
mkdir example/ext # C++ライブラリ用のディレクトリ

extディレクトリにて
example.cppとその他ヘッダーファイルを入れる。
swig用にexample.iを作成。
extconf.rb作成

swig -ruby -c++ example.i # example_wrap.cxx作成
ruby extconf.rb # Makefile作成
make

exampleディレクトリにて

rake build
gem install pkg/example-0.0.1.gem

非公開のローカルのgemをrailsで利用する場合

Gemfileに以下を追加

gem 'example', :path=>[インストールしたgemへのパス]
3
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
6