How can I install mysql and ruby and mysql/ruby on Mac OS X 10.6.6? I'm getting this error:
checking for mysql_query() in -lmysqlclient... no
ld: warning开发者_StackOverflow社区: in /usr/local/mysql/lib/libmysqlclient.dylib,
file was built for unsupported file format which is not the
architecture being linked (i386)
Go to http://macruby.org/downloads.html and download and install http://macruby.org/files/MacRuby%200.8.zip.
Go to http://mysql.com/downloads/mysql/ and download Mac OS X ver. 10.6 (x86, 64-bit), DMG Archive.
Go to http://tmtm.org/en/mysql/ruby/ and follow steps to download, then:
- run command:
ruby extconf.rb --with-mysql-config
- modify file "Makefile" in text editor and remove all i386 architecture flags i.e.
"-arch i386"
- run command:
make
- run command:
make install
- run command:
export rvm_archflags="-arch x86_64"
- run command:
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/
- run command:
ruby test.rb
- run command:
ruby ./test.rb -- [hostname [user [passwd [dbname [port [socket [flag]]]]]]]
Note:
If you get error like 'libmysqlclient not found
' when testing, you need to specify the directory in which the library is located so that make can find it.
% env LD_RUN_PATH=libmysqlclient.so directory make
Example:
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
Dan Benjamin's Hivelogic is great for this: http://hivelogic.com/articles/compiling-mysql-on-snow-leopard and http://hivelogic.com/articles/compiling-ruby-rubygems-and-rails-on-snow-leopard. Although Snow Leopard already has Ruby 1.8.7.
精彩评论