I've successfully installed the gem mysql2 with ruby under windows in the past, but now it's showing a weird error
checking for main() in -llibmysql... no
There is no typo, my console really shows -llibmysql and not -libmysql (and I think it should even be just libmysql without any dash)
I have followed all the instructions from this link, and my command looks like
gem install mysql2 -- '--with-mysql-lib="c:\Dev\MySQL_Connector\lib" --with-mysql-include="c:\Dev\MySQL_Connector\include"'
...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
C:/Bibliotheques/Dev/Ruby200-x64/bin/ruby.exe extconf.rb --with-mysql-lib=c:\Dev\MySQL_Connector\lib --with-mysql-in
clude=c:\Dev\MySQL_Connector\include
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
-----
Using --with-mysql-dir=c:\Dev\MySQL_Connector
-----
checking for main() in -llibmysql... no
Related
About
Currently, I`m building the Ruby on Rails project environment.
However, if I implement bundle install, the following error occurs.
I do not know where the cause is, I would like advice.
Environment
Ruby v2.5.3
Rails 5.2.2
MySQL 5.7
Run Command 1
$ bundle install
Output error
Errno::EACCES: Permission denied # rb_sysopen -
/Users/xxx/project_dir/vendor/bundle/ruby/2.5.0/gems/mysql2-0.5.2/CHANGELOG.md
An error occurred while installing mysql2 (0.5.2), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.5.2' --source 'https://rubygems.org/'` succeeds before bundling.
Run Command 2
$ sudo gem install mysql2 -v '0.5.2' --source 'https://rubygems.org/'
Output error
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
current directory: /Users/xxx/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/mysql2-0.5.2/ext/mysql2/Users/xxx/.rbenv/versions/2.5.3/bin/ruby -I /Users/xxx/.rbenv/versions/2.5.3/lib/ruby/site_ruby/2.5.0 -r ./siteconf20190220-84910-2gf7i1.rb extconf.rb
checking for rb_absint_size()... yes
checking for rb_absint_singlebit_p()... yes
checking for rb_wait_for_single_fd()... yes
-----
Using mysql_config at /usr/local/opt/mysql#5.7/bin/mysql_config
-----
checking for mysql.h... yes
checking for errmsg.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 MYSQL.net.vio in mysql.h... yes
checking for MYSQL.net.pvio in mysql.h... no
checking for MYSQL_ENABLE_CLEARTEXT_PLUGIN in mysql.h... yes
checking for SERVER_QUERY_NO_GOOD_INDEX_USED in mysql.h... yes
checking for SERVER_QUERY_NO_INDEX_USED in mysql.h... yes
checking for SERVER_QUERY_WAS_SLOW in mysql.h... yes
checking for MYSQL_OPTION_MULTI_STATEMENTS_ON in mysql.h... yes
checking for MYSQL_OPTION_MULTI_STATEMENTS_OFF in mysql.h... yes
checking for my_bool in mysql.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/opt/mysql#5.7/lib
-----
creating Makefile
current directory: /Users/xxx/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/mysql2-0.5.2/ext/mysql2
make "DESTDIR=" clean
current directory: /Users/xxx/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/mysql2-0.5.2/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
It seems that some system libraries are missing. As far as I understand you are using macos. So please try: xcode-select --install and bundle install
UPDATE
We had a private chat with #getty and we came up a solution. The problem was with some missing headers regarding to ruby program.
So we fixed the problem like following:
rbenv uninstall 2.5.3
CC=gcc rbenv install 2.5.3
rbenv local 2.5.3
bundle install
This solution would be applied to rvm or other version managers.
I try to install mysql2 gem with "gem install mysql2 -v '0.4.10'" on MacOS but always found this error.
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
current directory: /Users/sakuto/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/mysql2-0.4.10/ext/mysql2
- /Users/sakuto/.rbenv/versions/2.3.3/bin/ruby -r
./siteconf20190212-14889-1xapc5p.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 errmsg.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
MYSQL.net.vio in mysql.h... yes checking for MYSQL.net.pvio in
mysql.h... no checking for MYSQL_ENABLE_CLEARTEXT_PLUGIN in
mysql.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/8.0.15/lib
----- creating Makefile
To see why this extension failed to compile, please check the
mkmf.log which can be found here:
/Users/sakuto/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/extensions/x86_64-darwin-18/2.3.0-static/mysql2-0.4.10/mkmf.log
current directory:
/Users/sakuto/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/mysql2-0.4.10/ext/mysql2
make "DESTDIR=" clean
current directory:
/Users/sakuto/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/mysql2-0.4.10/ext/mysql2
make "DESTDIR=" compiling infile.c compiling client.c compiling
mysql2_ext.c compiling statement.c compiling result.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/sakuto/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/mysql2-0.4.10
for inspection. Results logged to
/Users/sakuto/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/extensions/x86_64-darwin-18/2.3.0-static/mysql2-0.4.10/gem_make.out
Try adding gem inside Gemfile in your ruby on rails project and run bundle install in command line.
for example:
gem 'mysql2', '~> 0.4.10'
I installed Ruby 2.0.0 and DevKit from RuyInstaller. I have an error message when I'm creating new project:
rails new testtest -d mysql
..... a lot of output here ........
Installing mysql2 (0.3.14)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
C:/Ruby200/bin/ruby.exe extconf.rb
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
How can I install dependencies to make this gem without any errors?
You need MySQL 32-bit (or MySQL Connector C) to compile mysql2 gem compiling on Windows (even if you are using a 64-bit version of the OS).
Follow these steps:
Download MySQL Server 32-bit .zip file (Alternatively MySQL Connector C is also fine)
Copy libmysql.dll to %RUBY_HOME%\bin (or simply add MySQL 32-bit lib directory to PATH)
Install mysql2 gem with --with-mysql-lib and --with-mysql-include options
gem install mysql2 -- '--with-mysql-lib="c:\path\to\32-bit-MySQL-Server\lib\opt" --with-mysql-include="c:\\path\to\32-bit-MySQL-Server\include"'
Here is my story. Tried to install mysql2 gem on windows 7 with devkit.
First you need to install connector libraries and headers.
Don't use default folder "Program Files", gem failed to include folders with spaces.
I've substed connector folder through subst X:\ "C:\Program File\Mysql Connector 6 C\"
and then used following cmd:
gem install mysql2 -- --with-mysql-dir=X:\
Then realised that I'm using 64 bit connector libraries with 32 bit ruby.
Reinstalled connector.
And then gem was successfully installed.
But failed to run, complaining on missing mysql dll. So, I've put libmysql.dll and *.lib to ruby\bin folder. And after all this was able to user mysql2 gem.
Hi I want to install Gitlab on Debian 7.0 when i want to install the bundle i get follor error by mysql2-0.3.11
root#v22013051598612672:/home/git/gitlab# gem install mysql2 -v '0.3.11'
Fetching: mysql2-0.3.11.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/usr/local/bin/ruby extconf.rb
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Gem files will remain installed in /usr/local/lib/ruby/gems/1.9.1 /gems/mysql2-0.3.11 for inspecti on.
Results logged to /usr/local/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11/ext/mysql2/gem_make.out
I have you a idea?
Mfg user2182545 (ternes3)
PS: I need it for GitLAB
Try to install mysql + libraries via apt-get install mysql-server libmysqlclient libmysqlclient-dev mysql-client mysql-common
The issue 754 mentions seeing this error even after gem install mysql2 and apt-get install libmysqlclient-dev.
But it also adds:
EDIT: Solved!
sudo apt-get install libmariadbclient16-dev
Check if this is the actual missing piece on your Debian.
I'm trying to install the mysql gem via
sudo gem install mysql --version 2.7
However, I get the following error:
Building native extensions. This could take a while...
...........
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
/usr/bin/ruby extconf.rb
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... yes
checking for mysql_query() in -lmysqlclient... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Any ideas?
somethings to try:
gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
of course use path of where your mysql_config is. mysql_config will be there if you've installed a mysql client
gem install mysql -- \
--with-mysql-include=/usr/include/mysql \
--with-mysql-lib=/usr/lib/mysql
use paths of where your lib and headers are for mysql.