When I install mysql2 by gem, I encounter some puzzles. I have been beset for 2 days. I've tried all this command:
gem install mysql2 -v '0.5.1' --source 'https://gems.ruby-china.com/' -- --with-mysql-lib="/usr/lib/mysql"
gem install mysql2 -v '0.5.1' --source 'https://gems.ruby-china.com/' -- --with-mysql-lib="/usr/lib64/mysql"
gem install mysql2 -v '0.5.1' --source 'https://gems.ruby-china.com/'
But all of those return me with the same error which shows below :
Building native extensions with: '--with-mysql-lib=/usr/lib/mysql'
This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
current directory: /usr/local/rvm/gems/ruby-2.3.0/gems/mysql2-0.5.1/ext/mysql2
/usr/local/rvm/rubies/ruby-2.3.0/bin/ruby -r ./siteconf20180719-13223-afd0n0.rb extconf.rb --with-mysql-lib=/usr/lib/mysql
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/bin/mysql_config
checking for mysql.h... yes
checking for errmsg.h... yes
checking for SSL_MODE_DISABLED in mysql.h... no
checking for MYSQL_OPT_SSL_ENFORCE in mysql.h... no
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
Setting libpath to /usr/lib64/mysql
creating Makefile
current directory: /usr/local/rvm/gems/ruby-2.3.0/gems/mysql2-0.5.1/ext/mysql2
make "DESTDIR=" clean
current directory: /usr/local/rvm/gems/ruby-2.3.0/gems/mysql2-0.5.1/ext/mysql2
make "DESTDIR="
compiling client.c
compiling result.c
compiling statement.c
statement.c: In function 'rb_raise_mysql2_stmt_error':
statement.c:47:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
VALUE rb_error_msg = rb_str_new2(mysql_stmt_error(stmt_wrapper->stmt));
^
statement.c:53:3: warning: ISO C90 forbenter code hereids mixed declarations and code [-Wdeclaration-after-statement]
rb_encoding *default_internal_enc = rb_default`enter code here`_internal_encoding();
^
In file included from ./mysql2_ext.h:39:0,
from statement.c:1:
statement.c: In function 'rb_mysql_stmt_execute':
./client.h:22:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
mysql_client_wrapper *wrapper; \
^
statement.c:261:3: note: in expansion of macro 'GET_CLIENT'
GET_CLIENT(stmt_wrapper->client);
^
statement.c:389:13: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
VALUE rb_val_as_string = rb_funcall(argv[i], intern_to_s, 0);
^
In file included from ./mysql2_ext.h:39:0,
from statement.c:1:
statement.c: In function 'rb_mysql_stmt_fields':
./client.h:22:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
mysql_client_wrapper *wrapper; \
^
statement.c:491:3: note: in expansion of macro 'GET_CLIENT'
GET_CLIENT(stmt_wrapper->client);
^
compiling mysql2_ext.c
compiling infile.c
linking shared-object mysql2/mysql2.so
/usr/bin/ld: cannot find -lmysqlclient
collect2: error: ld returned 1 exit status
make: *** [mysql2.so] Error 1
make failed, exit code 2
Gem files will remain installed in /usr/local/rvm/gems/ruby-2.3.0/gems/mysql2-0.5.1 for inspection.
Results logged to /usr/local/rvm/gems/ruby-2.3.0/extensions/x86_64-linux/2.3.0/mysql2-0.5.1/gem_make.out
and here are all my files about mysql