ln:/usr/lib/libmysqlclient.18.dylib:文件存在

时间:2013-08-22 19:05:03

标签: mysql ruby macos rake osx-mountain-lion

rake aborted!
dlopen(/Users/ava/.rvm/gems/ruby-2.0.0-p247/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle, 9): Library not loaded: /usr/local/lib/libmysqlclient.18.dylib
  Referenced from: /Users/ava/.rvm/gems/ruby-2.0.0-p247/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
  Reason: image not found - /Users/ava/.rvm/gems/ruby-2.0.0-p247/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle`

following解决:

$ sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib \
             /usr/lib/libmysqlclient.18.dylib
ln: /usr/lib/libmysqlclient.18.dylib: File exists

我的设置:

  • OSX 10.8.4
  • MySQL 5.1.71
  • libmysqlclient.16.dylib

    $ locate libmysqlclient.16.dylib
    /usr/lib/libmysqlclient.16.dylib
    /usr/local/Cellar/mysql51/5.1.71/lib/mysql/libmysqlclient.16.dylib
    
  • libmysqlclient.18.dylib

    $ locate libmysqlclient.18.dylib
    /usr/lib/libmysqlclient.18.dylib
    

.bash_profile,我有

export PATH="/usr/local/bin:$HOME/.rvm/bin:$HOME/bin:$PATH"
export DYLD_LIBRARY_PATH=/usr/local/bin/mysql

如何让这个耙子运行?我是否应该在libmysqlclient.18.dylib/usr/local/Cellar/mysql51/5.1.71/lib/mysql?如果是,我该如何创建它?

2 个答案:

答案 0 :(得分:2)

抱歉,如果我弄错了;没有Mac可以查看详细信息。

错误消息明确指出,mysql想要的库是:

/usr/local/lib/libmysqlclient.18.dylib

你的图书馆是:

/usr/lib/libmysqlclient.18.dylib

这绝对意味着,您的mysql安装在某种程度上已被破坏,但对于快速补丁,我建议使用软链接:

$ sudo ln -s /usr/lib/libmysqlclient.18.dylib /usr/local/lib/libmysqlclient.18.dylib

您可能在第一个解决方案中错误地放置了参数。

答案 1 :(得分:0)

如果您使用的是Bash,请指示Mac OS X按如下方式查找:

~/.bash_profile

export DYLD_LIBRARY_PATH=<location of mysqlclient.18.dylib>:$DYLD_LIBRARY_PATH

重启终端。

例如,我有以下内容:

$ ls -ld /usr/local/m*
lrwxr-xr-x   1 root  admin   27 May  5 14:28 /usr/local/mysql -> mysql-5.6.13-osx10.7-x86_64
drwxr-xr-x   3 root  wheel  102 May  5 13:13 /usr/local/mysql-5.5.29-osx10.6-x86
drwxr-xr-x  17 root  wheel  578 May  5 13:13 /usr/local/mysql-5.6.13-osx10.7-x86_64

$ head ~/.bash_profile
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH