I tried every solution similar to the question:錯誤:安裝mysql2時出錯:錯誤:無法構建gem本機擴展。在Mac 10.12
近日,筆者從Ubuntu的到Mac感動,我試圖安裝在塞拉利昂mysql的寶石和我已經安裝了Ruby,Rails的,Mysql的後
也是我型brew install mysql
和它的工作了下載MySQL但不是寶石,所以我的問題是不相似的。
我打這個mysql --version
和我mysql Ver 14.14 Distrib 5.7.16, for osx10.12 (x86_64) using EditLine wrapper
我試圖安裝mysql2創業板軌道建設一個新的應用程序
我打這個sudo gem install mysql2
和得到這個錯誤:
Password:
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
current directory: /Users/mohammed.elias/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/mysql2-0.4.5/ext/mysql2
/Users/mohammed.elias/.rbenv/versions/2.4.0/bin/ruby -r ./siteconf20170102-2045-18gcs95.rb extconf.rb
checking for rb_absint_size()... yes
checking for rb_absint_singlebit_p()... yes
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... no
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
checking for rb_big_cmp()... yes
-----
Using mysql_config at /usr/local/bin/mysql_config
-----
checking for mysql.h... yes
checking for SSL_MODE_DISABLED in mysql.h... yes
checking for SSL_MODE_PREFERRED in mysql.h... yes
checking for SSL_MODE_REQUIRED in mysql.h... yes
checking for SSL_MODE_VERIFY_CA in mysql.h... yes
checking for SSL_MODE_VERIFY_IDENTITY in 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.7.16/lib
-----
creating Makefile
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Users/mohammed.elias/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/extensions/x86_64-darwin-16/2.4.0-static/mysql2-0.4.5/mkmf.log
current directory: /Users/mohammed.elias/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/mysql2-0.4.5/ext/mysql2
make "DESTDIR=" clean
current directory: /Users/mohammed.elias/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/mysql2-0.4.5/ext/mysql2
make "DESTDIR="
compiling client.c
compiling infile.c
compiling mysql2_ext.c
compiling result.c
compiling statement.c
linking shared-object mysql2/mysql2.bundle
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
Gem files will remain installed in /Users/mohammed.elias/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/mysq l2-0.4.5 for inspection.
Results logged to /Users/mohammed.elias/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/extensions/x86_64-darwin-16/2.4.0-static/mysql2-0.4.5/gem_make.out
[錯誤安裝mysql2:無法構建gem原生擴展名](http://stackoverflow.com/questions/3608287/error-installing-mysql2-failed-to-build-gem-native-extension) – Ilya
從跟蹤中,我們可以看到構建系統找到了mysql頭文件,但是無法加載ssl文件(來自OpenSSL)。你可以嘗試一下[在github上的問題](https://github.com/brianmario/mysql2/issues/795)提供的解決方案。如果失敗了,你可能會通過運行'brew install openssl'來成功。 –
爲了什麼是值得的,我剛剛成功安裝了gem,全新安裝了Ruby 2.4.0。錯誤日誌裏有什麼'/Users/mohammed.elias/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/extensions/x86_64-darwin-16/2.4.0-static/mysql2-0.4。 5/mkmf.log'? – cobaltsoda