无法在centos 7上安装mysql2并出现libmysqlclient错误

时间:2018-07-19 06:21:20

标签: c ruby rubygems mysql2

当我通过gem安装mysql2时,我遇到了一些困惑。我被困扰了两天。 我已经尝试了所有以下命令:

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/'

但是所有这些人都以相同的错误返回我,如下所示:

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

这是我所有有关mysql的文件

1 个答案:

答案 0 :(得分:0)

您缺少mysqlclient。

请尝试按照此处的步骤操作:Ruby gem mysql2 install failing

在OSX上,尝试import sympy as sym import sympy.parsing.latex as sym_tex # requires sympy 1.2 def symbolic_solver(equation, unknown, some_symbol='x'): expr = equation.replace(unknown, some_symbol) eqn = sym_tex.parse_latex(expr) exec('%s = sym.Symbol("%s")'%(some_symbol, some_symbol)) try: # Sometimes Sympy throws a notimplemented error when it can not solve exec('sol = sym.solve(eqn, %s)'%(some_symbol)) except NotImplementedError: print('SymPy could not solve the equation.') print('Set the solution manually.') return sol equation = 'm\\cdot g\\cdot h_A + \\frac{1}{2}\\cdot m\\cdot {v_A}^2 = m\\cdot g\\cdot h_B + \\frac{1}{2}\\cdot m\\cdot {v_B}^2' unknown = 'v_B' sol = symbolic_solver(equation, unknown)

在最坏的情况下,您可能需要卸载mysql并重新安装它:https://github.com/brianmario/mysql2/issues/687#issuecomment-144811470