[mac] mysql2 gem: Don’t know how to set rpath on your system, if MySQL libraries are not in path mysql2 may not load

這幾天在裝 mysql2 gems 時發生如下的錯誤

Using mysql_config at /usr/local/bin/mysql_config
-----
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
-----
Don't know how to set rpath on your system, if MySQL libraries are not in path mysql2 may not load
-----
-----
Setting libpath to /usr/local/Cellar/mysql/5.6.25/lib
-----
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
compiling client.c
compiling infile.c
compiling mysql2_ext.c
compiling result.c
linking shared-object mysql2/mysql2.bundle
ld: warning: directory not found for option '-L/Users/travis/.sm/pkg/active/lib'
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [mysql2.bundle] Error 1

make failed, exit code 2

原因主要是 ld: library not found for -lssl

通常是 openssl 未安裝或路徑設定有誤

可以先試著重裝 openssl ,必且重新設定對應的環境變數

brew install openssl
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/

重新安裝 mysql2 gem 應該就正常囉!

參考資料:

https://stackoverflow.com/questions/30834421/error-when-trying-to-install-app-with-mysql2-gem/30837897#30837897?newreg=a89c9550c93f4e7c84db03b8c15ff3d9

Leave a Reply

Your email address will not be published. Required fields are marked *