Well, that didn't seem to go too well. It seems that somewhere in the
mkmf / extconf.rb soup the actual location of the mysql home has
gotten lost. The only way this will work is if mysql is installed in /
usr/local, the default for the distributed precompiled version is to
go in /usr/local/mysql.
$ which ruby
/usr/bin/ruby
$ ruby --version
ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0]
$ which rails
/usr/bin/rails
$ rails --version
Rails 2.2.2
$ which gem
/usr/bin/gem
$ gem --version
1.3.0
$ which mysql
/usr/local/mysql/bin/mysql
$ mysql --version
mysql Ver 14.12 Distrib 5.0.51a, for apple-darwin8.6.0 (powerpc)
using readline 5.0
$ gem list mysql
*** LOCAL GEMS ***
$ sudo env ARCHFLAGS="" gem install mysql
Password:
Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
extconf.rb install mysql
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... 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=/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/
ruby
--with-mysql-config
--without-mysql-config
--with-mysql-dir
--without-mysql-dir
--with-mysql-include
--without-mysql-include=${mysql-dir}/include
--with-mysql-lib
--without-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
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/
mysql-2.7 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/mysql-2.7/gem_make.out
$
I haven't figured out how to pass "--with-mysql-dir" or any of the
other extconf.rb variants in on the command line so here's what I did.
1) Download the source from
tmtm.org
2) Modify extconf.rb such that for line 15:
WAS: inc, lib = dir_config('mysql', '/usr/local')
IS: inc, lib = dir_config('mysql', '/usr/local/mysql')
3) Create a mysql.gemspec thus:
#################
require 'rubygems'
require 'rake'
version = Dir.pwd.split(pattern="-").last
spec = Gem::Specification.new do |s|
s.name = "mysql"
s.version = "#{version}"
s.email = "
to...@tmtm.org"
s.homepage = "
http://www.tmtm.org/en/mysql/ruby/"
s.platform = Gem::Platform::RUBY
s.summary = "MySQL/Ruby provides the same functions for Ruby
programs that the MySQL C API provides for C programs."
s.files = FileList['[A-Za-z]*'].to_a
s.extensions = ["./extconf.rb"]
end
if $0 == __FILE__
Gem::Builder.new(spec).build
end
#################
$ ruby --version
ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0]
$ ruby mysql.gemspec
WARNING: no author specified
WARNING: no rubyforge_project specified
WARNING: RDoc will not be generated (has_rdoc == false)
Successfully built RubyGem
Name: mysql
Version: 2.8
File: mysql-2.8.gem
$ gem --version
1.3.0
$ gem list mysql --local
*** LOCAL GEMS ***
$ sudo env ARCHFLAGS="" gem install mysql
Password:
Building native extensions. This could take a while...
Successfully installed mysql-2.8
1 gem installed
$ gem list mysql --local
*** LOCAL GEMS ***
mysql (2.8)
$ cd /Library/Ruby/Gems/1.8/gems/mysql-2.8
$ ruby test.rb -- localhost rick tu44stu44 test222mysql_test
Loaded suite test
Started
...................................................................................................................
Finished in 3.697758 seconds.
115 tests, 391 assertions, 0 failures, 0 errors
$
so what do you think about that?
Rick
On Dec 2, 11:24 pm, Frederick Cheung <
frederick.che...@gmail.com>