论坛首页 编程语言技术论坛

关于ruby mysql库安装的问题.

浏览 5293 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2007-04-15  
环境:Win XPSP2,ruby 1.8.6,mysql-ruby-2.7.3.tar.gz
安装时执行下面两个命令:
ruby extconf.rb
ruby extconf.rb --with-mysql-dir=D:/MySQL5 --with-mysql-include=D:/MySQL5/include --with-mysql-lib=D:/MySQL5/lib
皆报错误(mysql安装目录为D:/MySQL5):
checking for main() in libmysql.lib... 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.
打开mkmf.log文件,里面的内容如下:
have_library: checking for main() in libmysql.lib... -------------------- no

"cl -nologo -Feconftest -I. -ID:/ruby/lib/ruby/1.8/i386-mswin32 -I. -ID:/ruby/lib/ruby/1.8/i386-mswin32 -ID:/MySQL5/include -ID:/MySQL5/include -MD -Zi -O2b2xg- -G6 conftest.c msvcrt-ruby18-static.lib libmysql.lib oldnames.lib user32.lib advapi32.lib ws2_32.lib -link -libpath:"D:/ruby/lib" -libpath:"D:/MySQL5/lib" -stack:0x2000000"
checked program was:
/* begin */
1: #define WIN32_LEAN_AND_MEAN
2: #include <winsock2.h>
3: #include <windows.h>
4:
5: /*top*/
6: int main() { return 0; }
7: int t() { void ((*volatile p)()); p = (void ((*)()))main; return 0; }
/* end */

"cl -nologo -Feconftest -I. -ID:/ruby/lib/ruby/1.8/i386-mswin32 -I. -ID:/ruby/lib/ruby/1.8/i386-mswin32 -ID:/MySQL5/include -ID:/MySQL5/include -MD -Zi -O2b2xg- -G6 conftest.c msvcrt-ruby18-static.lib libmysql.lib oldnames.lib user32.lib advapi32.lib ws2_32.lib -link -libpath:"D:/ruby/lib" -libpath:"D:/MySQL5/lib" -stack:0x2000000"
checked program was:
/* begin */
1: /*top*/
2: int main() { return 0; }
3: int t() { main(); return 0; }
/* end */

有哪位遇到过吗,望!
   发表时间:2007-04-15  
gem install mysql
为什么要这么麻烦呢?
0 请登录后投票
   发表时间:2007-04-15  
gem install mysql

Successfully installed mysql-2.7.3-mswin32
Installing ri documentation for mysql-2.7.3-mswin32...
Installing RDoc documentation for mysql-2.7.3-mswin32...
While generating documentation for mysql-2.7.3-mswin32
... MESSAGE:   Unhandled special: Special: type=17, text="<!-- $Id: README.html,
v 1.20 2006-12-20 05:31:52 tommy Exp $ -->"
... RDOC args: --op D:/ruby/lib/ruby/gems/1.8/doc/mysql-2.7.3-mswin32/rdoc --exc
lude ext --main README --quiet ext README docs/README.html
(continuing with the rest of the installation)

貌似安装成功了.但我下面的测试代码却不能正常运行

require 'mysql'

def main()
  con=Mysql.new('localhost','root','aaaa','9fff_dev') 
  res = con.query('select * from user').result 
  for data in res 
  p data 
  end 
end
main()


报错: D:/railtest/t5/test/unit/dbi_test.rb:19:in `require': no such file to load -- mysql (LoadError)
from D:/railtest/t5/test/unit/dbi_test.rb:19
0 请登录后投票
   发表时间:2007-04-16  
首先在用mysql 的时候你的rails 工程中的数据库配置文件中的用户名应该重新建立,不要使用root。
有时会出现上面的错误!
其次上步完成后,你发现还是不行 会出现缺少libmysql.dll文件的错误(windows 系统)。
(unix 大概为 libmsql.o ?)
你可以到你的mysql的安装目录下lib/opt/libmysql.dll拷贝到你的c:/windows/system32下就可以了!
0 请登录后投票
论坛首页 编程语言技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics