Skip to main content
 首页 » 编程设计

mysql之Ruby之Gem之mysql之无法构建 gem native 扩展

2024年02月23日8zhwl

两天以来我遇到了一个无法解决的问题。我正在尝试在 debian 机器上安装 redmine。当安装 gem mysql 时,它失败了。我不知道该怎么办了。我的最后一个例子是你的帮助。

错误

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


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] 


文件

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 */ 
 
-------------------- 

请您参考如下方法:

看来您走在正确的道路上。即使您看起来已经安装了 mysql 库,您也需要确保 MySQL 开发头文件及其依赖项已完全安装,以便编译 MySQL gem。

尝试:

sudo apt-get install mysql-dev 

然后:

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

显然,确切的命令取决于 mysql-dev 文件的安装位置。