问题
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`
Ran the following to resolve:
$ sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib \
/usr/lib/libmysqlclient.18.dylib
ln: /usr/lib/libmysqlclient.18.dylib: File exists
My setup:
- 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
In .bash_profile
, I have
export PATH="/usr/local/bin:$HOME/.rvm/bin:$HOME/bin:$PATH"
export DYLD_LIBRARY_PATH=/usr/local/bin/mysql
How to get this rake running? Am I supposed to have libmysqlclient.18.dylib
under /usr/local/Cellar/mysql51/5.1.71/lib/mysql
too? If yes, how do I create it?
回答1:
Sorry, if I am mistaken; there is no Mac to check in details.
The error message clearly states, that the library mysql
wants is:
/usr/local/lib/libmysqlclient.18.dylib
while the library you have is:
/usr/lib/libmysqlclient.18.dylib
That definitely means, that your mysql
installation is somehow broken, but for the quick patch I would recommend soft linking:
$ sudo ln -s /usr/lib/libmysqlclient.18.dylib /usr/local/lib/libmysqlclient.18.dylib
You have likely misplaced arguments within your first solution try.
回答2:
Instruct Mac OS X to find it as follows, if you are using Bash:
In your ~/.bash_profile
:
export DYLD_LIBRARY_PATH=<location of mysqlclient.18.dylib>:$DYLD_LIBRARY_PATH
Restart terminal.
For example, I have the following:
$ 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
来源:https://stackoverflow.com/questions/18388864/ln-usr-lib-libmysqlclient-18-dylib-file-exists