2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[ちょっとしたメモ] MSYS2上のRubyでsqlite3 gemをインストールしたかった

Posted at

前提

  • RubyはMSYS2のpacmanでインストールしている

遭遇したエラー

gem install sqlite3の結果、以下のエラーが。

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

    current directory: /usr/lib/ruby/gems/2.3.0/gems/sqlite3-1.3.12/ext/sqlite3
/usr/bin/ruby.exe -r ./siteconf20170104-5380-12c9rum.rb extconf.rb
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    
    【中略】
    
/usr/lib/ruby/2.3.0/mkmf.rb:457:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
        from /usr/lib/ruby/2.3.0/mkmf.rb:542:in `try_link0'
        from /usr/lib/ruby/2.3.0/mkmf.rb:557:in `try_link'
        from /usr/lib/ruby/2.3.0/mkmf.rb:658:in `try_ldflags'
        from /usr/lib/ruby/2.3.0/mkmf.rb:1814:in `pkg_config'
        from extconf.rb:27:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /usr/lib/ruby/gems/2.3.0/extensions/x86_64-unknown/2.3.0/sqlite3-1.3.12/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /usr/lib/ruby/gems/2.3.0/gems/sqlite3-1.3.12 for inspection.
Results logged to /usr/lib/ruby/gems/2.3.0/extensions/x86_64-unknown/2.3.0/sqlite3-1.3.12/gem_make.out

対策

これだけ見ても、"probably lack of necessary
libraries and/or headers"(おそらくライブラリかヘッダがない)と書かれているだけで、具体的に何をすればよいのかわからない。

ただ、"please check the mkmf.log which can be found here"(ここに記載されているmkmf.logをチェックしてください)という指示通りにファイルを見ると、gccのオプションの-lgmp-lcryptで失敗していたことが判明。

結局、以下のコマンドで解決した。

pacman -S libsqlite-devel gmp-devel libcrypt-devel

※これは私の場合です。mkmf.logを見ると、もっと別のライブラリが必要とされているかもしれません。

2
2
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
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?