You may receive the above error in the mkmf.log file when attempting to install the MySQL gem. A sample of the log file errors is below.
How to Resolve:Install mysql-devel via yum using the following command.
- [root@server ~]#yum install mysql-devel
First Gem Install Attempt with Error:
- [root@server ~]# env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/lib64/mysql/mysql_config -with-mysql-dir=/var/lib/mysql
- Building native extensions. This could take a while...
- ERROR: Error installing mysql:
- ERROR: Failed to build gem native extension.
- /usr/local/bin/ruby extconf.rb install mysql -- --with-mysql-config=/usr/lib64/mysql/mysql_config -with-mysql-dir=/var/lib/mysql
- checking for mysql_ssl_set()... no
- checking for mysql.h... no
- checking for mysql/mysql.h... no
- *** 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:
- --with-opt-dir
- --without-opt-dir
- --with-opt-include
- --without-opt-include=${opt-dir}/include
- --with-opt-lib
- --without-opt-lib=${opt-dir}/lib
- --with-make-prog
- --without-make-prog
- --srcdir=.
- --curdir
- --ruby=/usr/local/bin/ruby
- --with-mysql-config
- Gem files will remain installed in /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7 for inspection.
- Results logged to /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7/gem_make.out
Log File Error Snippet:
- have_header: checking for mysql.h... -------------------- no
- "gcc -E -I. -I/usr/local/lib/ruby/1.8/x86_64-linux -I. -I/usr/include/mysql -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtun
- e=generic -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv -g -O2 conftest.c -o conftest.i"
- conftest.c:1:19: error: mysql.h: No such file or directory
- checked program was:
- /* begin */
- 1: #include
- /* end */
- --------------------
- have_header: checking for mysql/mysql.h... -------------------- no
- "gcc -E -I. -I/usr/local/lib/ruby/1.8/x86_64-linux -I. -I/usr/include/mysql -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtun
- e=generic -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv -g -O2 conftest.c -o conftest.i"
- conftest.c:1:25: error: mysql/mysql.h: No such file or directory
- checked program was:
- /* begin */
- 1: #include
- /* end */
- --------------------
So again to resolve the issue install mysql-devel via yum and then issue the same install command which should install correctly this time.