如何在Mac OS X 10.6.6上安装mysql和ruby以及mysql / ruby?我收到了这个错误:
checking for mysql_query() in -lmysqlclient... no
ld: warning: in /usr/local/mysql/lib/libmysqlclient.dylib,
file was built for unsupported file format which is not the
architecture being linked (i386)
答案 0 :(得分:1)
转到http://macruby.org/downloads.html并下载并安装http://macruby.org/files/MacRuby%200.8.zip。
转到http://mysql.com/downloads/mysql/并下载Mac OS X版。 10.6(x86,64位),DMG档案。
转到http://tmtm.org/en/mysql/ruby/并按照步骤下载,然后:
ruby extconf.rb --with-mysql-config
"-arch i386"
make
make install
export rvm_archflags="-arch x86_64"
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/
ruby test.rb
ruby ./test.rb -- [hostname [user [passwd [dbname [port [socket [flag]]]]]]]
注意:
如果在测试时遇到类似'libmysqlclient not found
'的错误,则需要指定库所在的目录,以便make可以找到它。
% env LD_RUN_PATH=libmysqlclient.so directory make
示例:
my = Mysql.new(hostname, username, password, databasename)
st = my.prepare("insert into tblname (col1,col2,col3) values (?,?,?)")
st.execute("abc",123,Time.now)
st.prepare("select col1,col2,col3 from tblname")
st.execute
st.fetch # => ["abc", 123, #<Mysql::Time:2005-07-24 23:52:55>]
st.close
答案 1 :(得分:0)
Dan Benjamin的Hivelogic非常适合:http://hivelogic.com/articles/compiling-mysql-on-snow-leopard和http://hivelogic.com/articles/compiling-ruby-rubygems-and-rails-on-snow-leopard。虽然Snow Leopard已经拥有Ruby 1.8.7。