Necro_KOT Necro_KOT - 1 year ago 152
Ruby Question

Not able to install gems "mysql2, mariadb 10.1" in Ubuntu 16.04 Xenial

I have working mariadb 10.1 server.
I install ruby 2.3.0 on ubuntu 16.04.
I install libmariadbd-dev and libmariadbclient-dev.
When I try "gem install mysql2", then a recive message:

Building native extensions with: '--with-mysql-dir=/usr/local/mysql'
This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.

current directory: /var/lib/gems/2.3.0/gems/mysql2-0.4.4/ext/mysql2
/usr/bin/ruby2.3 -r ./siteconf20160615-5183-kj9yds.rb extconf.rb --with-mysql-dir=/usr/local/mysql
checking for ruby/thread.h... *** 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:456: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:587:in `try_cpp'
from /usr/lib/ruby/2.3.0/mkmf.rb:1091:in `block in have_header'
from /usr/lib/ruby/2.3.0/mkmf.rb:942:in `block in checking_for'
from /usr/lib/ruby/2.3.0/mkmf.rb:350:in `block (2 levels) in postpone'
from /usr/lib/ruby/2.3.0/mkmf.rb:320:in `open'
from /usr/lib/ruby/2.3.0/mkmf.rb:350:in `block in postpone'
from /usr/lib/ruby/2.3.0/mkmf.rb:320:in `open'
from /usr/lib/ruby/2.3.0/mkmf.rb:346:in `postpone'
from /usr/lib/ruby/2.3.0/mkmf.rb:941:in `checking_for'
from /usr/lib/ruby/2.3.0/mkmf.rb:1090:in `have_header'
from extconf.rb:16:in `<main>'

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


extconf failed, exit code 1

Gem files will remain installed in /var/lib/gems/2.3.0/gems/mysql2-0.4.4 for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/mysql2-0.4.4/gem_make.out

And I can`t find how to build this gem.

Answer Source

Gem in this situation need 3 packets.

sudo apt-get install libnetcdf-dev libssl-dev libcrypto++-dev
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download