rss· 投稿· 设为首页· 加入收藏· 繁體版
当前位置: 火魔网 » 程序开发 » Ruby

SuSE10.2下MySQL-Ruby的安装

    以前在Linux下安装Ruby的MySQL驱动虽然磕磕绊绊,但是都算顺利。总的说来,有两种安装方式:
    1、gem安装。直接运行gem install mysql,选上相应平台即可。
    2、包安装。到http://www.tmtm.org/en/mysql/ruby/下载一个mysql-ruby的驱动,
    tar xvfz mysql-ruby-2.7.4.tar.gz
    cd mysql-ruby-2.7.4
    ruby extconf.rb --with-mysql-lib=/usr/lib/mysql
    即可。     不幸的是,这次在SuSE10.2下安装却朋到了麻烦。不管是用第一种还是第二中方式,一直都提示:
    can't find header files for ruby
    奇怪,缺少ruby的头文件?打开YaST一查,发现Ruby装了,但是Ruby-Devel没有安装。装上试试? checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... 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/ruby
        --with-mysql-config
        --without-mysql-config
        --with-mysql-dir
        --with-mysql-include
        --without-mysql-include=${mysql-dir}/include
        --with-mysql-lib=${mysql-dir}/lib
        --with-mysqlclientlib
        --without-mysqlclientlib
        --with-mlib
        --without-mlib
        --with-mysqlclientlib
        --without-mysqlclientlib
        --with-zlib
        --without-zlib
        --with-mysqlclientlib
        --without-mysqlclientlib
        --with-socketlib
        --without-socketlib
        --with-mysqlclientlib
        --without-mysqlclientlib
        --with-nsllib
        --without-nsllib
        --with-mysqlclientlib
        --without-mysqlclientlib
        --with-mygcclib
        --without-mygcclib
        --with-mysqlclientlib
        --without-mysqlclientlib
    缺少库文件或者是头文件啊。由于命令行已经给出MySQL Lib的位置:
ruby extconf.rb --with-mysql-lib=/usr/lib/mysql
    怀疑是头文件缺乏导致。到/usr/include下,没有找到MySQL的任何东西。缺乏Devel?打开YaST,找到MySQL-Devel,装上。/usr/include/mysql有了。再来一次:
/tmp/ruby/mysql-ruby-2.7.4 # ruby extconf.rb --with-mysql-dir=/usr/share/mysql/ --with-mysql-lib=/usr/lib/mysql/
checking for mysql_query() in -lmysqlclient... yes
checking for mysql_ssl_set()... yes
checking for mysql.h... no
checking for mysql/mysql.h... yes
creating Makefile 接下来就好办了
make
make install 当然,我们还可以试试:
gem install mysql
选mysql 2.7(ruby) Building native extensions.  This could take a while...
Successfully installed mysql-2.7     至此MySql-ruby安装完成。
    总结一下,MySQL-ruby安装需要的东西:
    1、Ruby-devel,没有它,就没有ruby的头文件;
    2、mysql
    3、mysql-devel
顶一下
(0)
踩一下
(0)