15

我有一个简单的 MySQL 表:

% mysql -u rampion dev -e 'describe person'
+-------+--------------+------+-----+---------+----------------+
| Field | Type         | Null | Key | Default | Extra          |
+-------+--------------+------+-----+---------+----------------+
| id    | int(11)      | NO   | UNI | NULL    | auto_increment |
| uid   | varchar(256) | NO   | PRI | NULL    |                |
+-------+--------------+------+-----+---------+----------------+

还有一个我想运行的简单 DataMapper 脚本:

# temp.rb
require 'rubygems'
require 'datamapper'

DataMapper::Logger.new($stdout, :debug)
DataMapper.setup(:default, "mysql://rampion@localhost/dev")

class Person
  include DataMapper::Resource
  property :id,     Serial
  property :uid,    String
end

DataMapper.finalize

p Person.first_or_create(:uid => 'Steve')

但是当我运行它时,我得到动态链接器错误:

% ruby temp.rb
~/.rvm/gems/ruby-1.8.7-p334/gems/dm-validations-1.0.2/lib/dm-validations.rb:33: warning: already initialized constant OrderedHash
DataObjects::URI.new with arguments is deprecated, use a Hash of URI components (~/.rvm/gems/ruby-1.8.7-p334/gems/dm-do-adapter-1.0.2/lib/dm-do-adapter/adapter.rb:215:in `new') 
dyld: lazy symbol binding failed: Symbol not found: _mysql_init
  Referenced from: ~/.rvm/gems/ruby-1.8.7-p334/gems/do_mysql-0.10.12/lib/do_mysql/do_mysql.bundle
  Expected in: flat namespace

dyld: Symbol not found: _mysql_init
  Referenced from: ~/.rvm/gems/ruby-1.8.7-p334/gems/do_mysql-0.10.12/lib/do_mysql/do_mysql.bundle
  Expected in: flat namespace

zsh: trace trap  ruby temp.rb

LD_LIBRARY_PATH设置为/usr/local/mysql/lib,这是我安装 MySQL 的地方,它似乎_mysql_init在那里定义:

% grep '_mysql_init' $LD_LIBRARY_PATH/libmysqlclient.18.dylib
Binary file /usr/local/mysql/lib/libmysqlclient.18.dylib matches

我不知道我需要做什么来解决这个问题。

4

0 回答 0