I tried to install mysql using below command
gem install mysql2 -v '0.3.18'However I am getting the below error
Fetching: mysql2-0.3.18.gem (100%) Building native extensions. This could take a while... ERROR: Error installing mysql2: ERROR: Failed to build gem native extension. /home/jophy/.rvm/rubies/ruby-2.2.1/bin/ruby -r ./siteconf20170221-7481-38xom2.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.When I opened mkmf.log, I could find the below error:-
/usr/bin/ld: cannot find -lmysqlclient
collect2: error: ld returned 1 exit status 2 1 Answer
As @steeldriver mentions in his comment, you need to install the libmysqlclient-dev package which is available for all currently supported versions of Ubuntu from Precise through Zesty and can be installed Either through the Software Center or from the CLI (terminal) with the command sudo apt-get install libmysqlclient-dev
Sources:
3