Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby - Gem - mysql - Failed to build gem native extension

since two days I'm facing a problem I can't solve. I'm trying to install redmine on a debian machine. When it comes to installation for the gem mysql it fails. I don't know what to do anymore. My last instance is your help.

Error

root@host:~# gem1.8 install mysql
Building native extensions.  This could take a while...
ERROR:  Error installing mysql:
 ERROR: Failed to build gem native extension.

/usr/bin/ruby1.8 extconf.rb
checking for mysql_ssl_set()... no
checking for rb_str_set_len()... no
checking for rb_thread_start_timer()... 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/bin/ruby1.8
 --with-mysql-config
 --without-mysql-config


Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/mysql-2.8.1 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out

What I've tried

  • Installing packages by instruction: http://wiki.rubyonrails.org/database-support/mysql#linux_ubuntu
  • installing with mysql_config parameter
    root@host:~# find / -name mysql_config
    /usr/bin/mysql_config
    root@host:~# gem1.8 install mysql -- --with-mysql-config=/usr/bin/mysql_config


System

user@host:~# uname -a  
Linux www.example.org 2.6.18-028stab070.4 #1 SMP Tue Aug 17 18:32:47 MSD 2010 x86_64 GNU/Linux
root@s15428277:~# aptitude search '~i (mysql|ruby)|mysql.*dev'
i A libdbd-mysql-perl                                                     - A Perl5 database interface to the MySQL database                                
p   libghc6-hsql-mysql-dev                                                - Multi-Database Interface System for Haskell                                     
p   libgnademysql-dev                                                     - GNat Ada Database Environment - MySQL programming interface                     
p   liblua5.1-sql-mysql-dev                                               - luasql development files for the lua language version 5.1                       
i   libmysql++-dev                                                        - mysql C++ library bindings (development)                                        
i A libmysql++2c2a                                                        - mysql C++ library bindings (runtime)                                            
p   libmysql-ocaml-dev                                                    - OCaml bindings for MySql                                                        
v   libmysqlclient-dev                                                    -                                                                                 
i   libmysqlclient15-dev                                                  - MySQL database development files                                                
i A libmysqlclient15off                                                   - MySQL database client library                                                   
i   libopenssl-ruby1.8                                                    - OpenSSL interface for Ruby 1.8                                                  
i A libreadline-ruby1.8                                                   - Readline interface for Ruby 1.8                                                 
i A libruby1.8                                                            - Libraries necessary to run Ruby 1.8                                             
i   libsqlite3-ruby1.8                                                    - SQLite3 interface for Ruby 1.8                                                  
i A mysql-client-5.0                                                      - MySQL database client binaries                                                  
i A mysql-common                                                          - MySQL database common files                                                     
i   mysql-server                                                          - MySQL database server (metapackage depending on the latest version)             
i A mysql-server-5.0                                                      - MySQL database server binaries                                                  
i   ruby1.8                                                               - Interpreter of object-oriented scripting language Ruby 1.8                      
i   ruby1.8-dev                                                           - Header files for compiling extension modules for the Ruby 1.8      
root@host:~# gem1.8 --version
1.3.7
root@host:~# ruby1.8 --version
ruby 1.8.7 (2008-08-11 patchlevel 72) [x86_64-linux]


Files

mkmf.log

have_func: checking for mysql_ssl_set()... -------------------- no

"cc -o conftest -I. -I/usr/lib/ruby/1.8/x86_64-linux -I/usr/lib/ruby/gems/1.8/gems/mysql-2.8.1/ext/mysql_api    -I/usr/include/mysql  -DBIG_JOINS=1 -fPIC -fno-strict-aliasing -g -g -O2  -fPIC   conftest.c  -L. -L/usr/lib -L.  -rdynamic -Wl,-export-dynamic    -L/usr/lib/mysql -lmysqlclient  -lruby1.8-static -L/usr/lib/mysql -lmysqlclient  -lpthread -ldl -lcrypt -lm   -lc"
checked program was:
/* begin */
1: /*top*/
2: int main() { return 0; }
3: int t() { void ((*volatile p)()); p = (void ((*)()))mysql_ssl_set; return 0; }
/* end */

"cc -o conftest -I. -I/usr/lib/ruby/1.8/x86_64-linux -I/usr/lib/ruby/gems/1.8/gems/mysql-2.8.1/ext/mysql_api    -I/usr/include/mysql  -DBIG_JOINS=1 -fPIC -fno-strict-aliasing -g -g -O2  -fPIC   conftest.c  -L. -L/usr/lib -L.  -rdynamic -Wl,-export-dynamic    -L/usr/lib/mysql -lmysqlclient  -lruby1.8-static -L/usr/lib/mysql -lmysqlclient  -lpthread -ldl -lcrypt -lm   -lc"
checked program was:
/* begin */
1: /*top*/
2: int main() { return 0; }
3: int t() { mysql_ssl_set(); return 0; }
/* end */

--------------------

have_func: checking for rb_str_set_len()... -------------------- no

"cc -o conftest -I. -I/usr/lib/ruby/1.8/x86_64-linux -I/usr/lib/ruby/gems/1.8/gems/mysql-2.8.1/ext/mysql_api    -I/usr/include/mysql  -DBIG_JOINS=1 -fPIC -fno-strict-aliasing -g -g -O2  -fPIC   conftest.c  -L. -L/usr/lib -L.  -rdynamic -Wl,-export-dynamic    -L/usr/lib/mysql -lmysqlclient  -lruby1.8-static -L/usr/lib/mysql -lmysqlclient  -lpthread -ldl -lcrypt -lm   -lc"
checked program was:
/* begin */
1: /*top*/
2: int main() { return 0; }
3: int t() { void ((*volatile p)()); p = (void ((*)()))rb_str_set_len; return 0; }
/* end */

"cc -o conftest -I. -I/usr/lib/ruby/1.8/x86_64-linux -I/usr/lib/ruby/gems/1.8/gems/mysql-2.8.1/ext/mysql_api    -I/usr/include/mysql  -DBIG_JOINS=1 -fPIC -fno-strict-aliasing -g -g -O2  -fPIC   conftest.c  -L. -L/usr/lib -L.  -rdynamic -Wl,-export-dynamic    -L/usr/lib/mysql -lmysqlclient  -lruby1.8-static -L/usr/lib/mysql -lmysqlclient  -lpthread -ldl -lcrypt -lm   -lc"
checked program was:
/* begin */
1: /*top*/
2: int main() { return 0; }
3: int t() { rb_str_set_len(); return 0; }
/* end */

--------------------

have_func: checking for rb_thread_start_timer()... -------------------- no

"cc -o conftest -I. -I/usr/lib/ruby/1.8/x86_64-linux -I/usr/lib/ruby/gems/1.8/gems/mysql-2.8.1/ext/mysql_api    -I/usr/include/mysql  -DBIG_JOINS=1 -fPIC -fno-strict-aliasing -g -g -O2  -fPIC   conftest.c  -L. -L/usr/lib -L.  -rdynamic -Wl,-export-dynamic    -L/usr/lib/mysql -lmysqlclient  -lruby1.8-static -L/usr/lib/mysql -lmysqlclient  -lpthread -ldl -lcrypt -lm   -lc"
checked program was:
/* begin */
1: /*top*/
2: int main() { return 0; }
3: int t() { void ((*volatile p)()); p = (void ((*)()))rb_thread_start_timer; return 0; }
/* end */

"cc -o conftest -I. -I/usr/lib/ruby/1.8/x86_64-linux -I/usr/lib/ruby/gems/1.8/gems/mysql-2.8.1/ext/mysql_api    -I/usr/include/mysql  -DBIG_JOINS=1 -fPIC -fno-strict-aliasing -g -g -O2  -fPIC   conftest.c  -L. -L/usr/lib -L.  -rdynamic -Wl,-export-dynamic    -L/usr/lib/mysql -lmysqlclient  -lruby1.8-static -L/usr/lib/mysql -lmysqlclient  -lpthread -ldl -lcrypt -lm   -lc"
checked program was:
/* begin */
1: /*top*/
2: int main() { return 0; }
3: int t() { rb_thread_start_timer(); return 0; }
/* end */

--------------------

have_header: checking for mysql.h... -------------------- no

"cc -E -I. -I/usr/lib/ruby/1.8/x86_64-linux -I/usr/lib/ruby/gems/1.8/gems/mysql-2.8.1/ext/mysql_api    -I/usr/include/mysql  -DBIG_JOINS=1 -fPIC -fno-strict-aliasing -g -g -O2  -fPIC    conftest.c -o conftest.i"
checked program was:
/* begin */
1: #include 
/* end */

--------------------

have_header: checking for mysql/mysql.h... -------------------- no

"cc -E -I. -I/usr/lib/ruby/1.8/x86_64-linux -I/usr/lib/ruby/gems/1.8/gems/mysql-2.8.1/ext/mysql_api    -I/usr/include/mysql  -DBIG_JOINS=1 -fPIC -fno-strict-aliasing -g -g -O2  -fPIC    conftest.c -o conftest.i"
checked program was:
/* begin */
1: #include 
/* end */

--------------------
like image 492
JohannesM Avatar asked Dec 22 '22 20:12

JohannesM


1 Answers

It looks like you are on the right track. Even though you appear to have the mysql libraries installed, you need to ensure that the MySQL development header files and their dependencies are fully installed in order for the MySQL gem to be compiled.

Try:

sudo apt-get install mysql-dev

And then:

sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

Clearly, the exact command depends upon where the mysql-dev files are installed.

like image 76
Scott Avatar answered Dec 28 '22 08:12

Scott