如何在 Mac OS X 10.6.6 上安装 mysql 和 ruby​​ 以及 mysql/ruby

发布于 2024-10-17 11:00:38 字数 309 浏览 3 评论 0原文

如何在 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)

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: in /usr/local/mysql/lib/libmysqlclient.dylib, 
     file was built for unsupported file format which is not the
     architecture being linked (i386)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

岁月染过的梦 2024-10-24 11:00:38

前往 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/ 并按照步骤操作下载,然后:

  1. 运行命令: ruby extconf.rb --with-mysql-config
  2. 在文本编辑器中修改文件“Makefile”并删除所有 i386 架构标志,即 “-arch i386”
  3. 运行命令:make
  4. 运行命令:make install
  5. 运行命令:export rvm_archflags="-arch x86_64"
  6. 运行命令:export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/
  7. 运行命令:ruby test.rb
  8. 运行命令:ruby ./test.rb -- [主机名[用户[密码]] 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

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:

  1. run command: ruby extconf.rb --with-mysql-config
  2. modify file "Makefile" in text editor and remove all i386 architecture flags i.e. "-arch i386"
  3. run command: make
  4. run command: make install
  5. run command: export rvm_archflags="-arch x86_64"
  6. run command: export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/
  7. run command: ruby test.rb
  8. 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
遮云壑 2024-10-24 11:00:38

Dan Benjamin 的 Hivelogic 对此非常有用:http://hivelogic.com/articles/compiling -mysql-on-snow-leopardhttp://hivelogic.com/articles/compiling-ruby-rubygems-and-rails-on-snow-leopard。虽然 Snow Leopard 已经有了 Ruby 1.8.7。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文