错误:mysql gem的捆绑包安装失败

时间:2019-10-21 09:12:06

标签: mysql ruby-on-rails ruby rubygems mysql-error-1064

对不起,我的英语不好。 我正在尝试在RoR中安装mysql,但尝试时出现此错误:

Installing mysql2 0.4.10 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/mysql2-0.4.10/ext/mysql2
C:/Ruby25-x64/bin/ruby.exe -r ./siteconf20191021-9148-s1v8ez.rb extconf.rb
--with-opt-dir=/usr/local/opt/openssl
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
checking for mysql_query() in -lmysqlclient... no
-----
mysql client is missing. Check your installation of MySQL or Connector/C, and
try again.
-----
*** 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.

Provided configuration options:
        --with-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=C:/Ruby25-x64/bin/$(RUBY_BASE_NAME)
        --with-mysql-dir
        --without-mysql-dir
        --with-mysql-include
        --without-mysql-include=${mysql-dir}/include
        --with-mysql-lib
        --without-mysql-lib=${mysql-dir}/lib
        --with-mysql-config
        --without-mysql-config
        --with-mysql-dir
        --without-mysql-dir
        --with-mysql-include
        --without-mysql-include=${mysql-dir}/include
        --with-mysql-lib
        --without-mysql-lib=${mysql-dir}/lib
        --with-mysqlclientlib
        --without-mysqlclientlib

To see why this extension failed to compile, please check the mkmf.log which can
be found here:

C:/Ruby25-x64/lib/ruby/gems/2.5.0/extensions/x64-mingw32/2.5.0/mysql2-0.4.10/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/mysql2-0.4.10 for inspection.
Results logged to
C:/Ruby25-x64/lib/ruby/gems/2.5.0/extensions/x64-mingw32/2.5.0/mysql2-0.4.10/gem_make.out

An error occurred while installing mysql2 (0.4.10), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.4.10' --source 'https://rubygems.org/'`
succeeds before bundling.

In Gemfile:
  mysql2

我已经看过这里所有的旧帖子,并且尝试解决一些问题,但是没有用。 我已经安装了ruby 2.5和Rails5。我正在尝试安装gem mysql2 -v'4.0.10'。 你能帮我吗?

2 个答案:

答案 0 :(得分:0)

它抱怨缺少mysql客户端 试试这个命令

  

sudo apt-get install libmysqlclient-dev

然后重新启动mysql,然后尝试捆绑

更多:如果您要从头开始安装新应用,请点击此链接 https://gorails.com/setup/ubuntu/18.04#mysql

答案 1 :(得分:0)

d.run or similar hacks谢谢回答。抱歉,我没有指定我使用Windows,而且我已经安装了带有--with-mysqlclientlib选项的gem。 在我的mkmf.log文件中,存在一些错误:

have_func: checking for rb_absint_size()... -------------------- yes

"x86_64-w64-mingw32-gcc -o conftest.exe -IC:/Ruby25-x64/include/ruby-2.5.0/x64-mingw32 -IC:/Ruby25-x64/include/ruby-2.5.0/ruby/backward -IC:/Ruby25-x64/include/ruby-2.5.0 -I. -I/usr/local/opt/openssl/include -D_FORTIFY_SOURCE=2 -D__USE_MINGW_ANSI_STDIO=1 -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64  -O3 -fno-fast-math conftest.c  -L. -LC:/Ruby25-x64/lib -L/usr/local/opt/openssl/lib -L. -pipe -s     -lx64-msvcrt-ruby250  -lgmp -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi  "
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <winsock2.h>
4: #include <windows.h>
5: int main(int argc, char **argv)
6: {
7:   return 0;
8: }
/* end */

"x86_64-w64-mingw32-gcc -o conftest.exe -IC:/Ruby25-x64/include/ruby-2.5.0/x64-mingw32 -IC:/Ruby25-x64/include/ruby-2.5.0/ruby/backward -IC:/Ruby25-x64/include/ruby-2.5.0 -I. -I/usr/local/opt/openssl/include -D_FORTIFY_SOURCE=2 -D__USE_MINGW_ANSI_STDIO=1 -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64  -O3 -fno-fast-math conftest.c  -L. -LC:/Ruby25-x64/lib -L/usr/local/opt/openssl/lib -L. -pipe -s     -lx64-msvcrt-ruby250  -lgmp -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi  "
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: #include <winsock2.h>
 4: #include <windows.h>
 5: 
 6: /*top*/
 7: extern int t(void);
 8: int main(int argc, char **argv)
 9: {
10:   if (argc > 1000000) {
11:     printf("%p", &t);
12:   }
13: 
14:   return 0;
15: }
16: int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_absint_size; return !p; }
/* end */

--------------------

have_func: checking for rb_absint_singlebit_p()... -------------------- yes

"x86_64-w64-mingw32-gcc -o conftest.exe -IC:/Ruby25-x64/include/ruby-2.5.0/x64-mingw32 -IC:/Ruby25-x64/include/ruby-2.5.0/ruby/backward -IC:/Ruby25-x64/include/ruby-2.5.0 -I. -I/usr/local/opt/openssl/include -D_FORTIFY_SOURCE=2 -D__USE_MINGW_ANSI_STDIO=1 -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64  -O3 -fno-fast-math conftest.c  -L. -LC:/Ruby25-x64/lib -L/usr/local/opt/openssl/lib -L. -pipe -s     -lx64-msvcrt-ruby250  -lgmp -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi  "
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: #include <winsock2.h>
 4: #include <windows.h>
 5: 
 6: /*top*/
 7: extern int t(void);
 8: int main(int argc, char **argv)
 9: {
10:   if (argc > 1000000) {
11:     printf("%p", &t);
12:   }
13: 
14:   return 0;
15: }
16: int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_absint_singlebit_p; return !p; }
/* end */

--------------------

have_func: checking for rb_wait_for_single_fd()... -------------------- yes

"x86_64-w64-mingw32-gcc -o conftest.exe -IC:/Ruby25-x64/include/ruby-2.5.0/x64-mingw32 -IC:/Ruby25-x64/include/ruby-2.5.0/ruby/backward -IC:/Ruby25-x64/include/ruby-2.5.0 -I. -I/usr/local/opt/openssl/include -D_FORTIFY_SOURCE=2 -D__USE_MINGW_ANSI_STDIO=1 -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64  -O3 -fno-fast-math conftest.c  -L. -LC:/Ruby25-x64/lib -L/usr/local/opt/openssl/lib -L. -pipe -s     -lx64-msvcrt-ruby250  -lgmp -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi  "
conftest.c: In function 't':
conftest.c:16:57: error: 'rb_wait_for_single_fd' undeclared (first use in this function)
   16 | int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_wait_for_single_fd; return !p; }
      |                                                         ^~~~~~~~~~~~~~~~~~~~~
conftest.c:16:57: note: each undeclared identifier is reported only once for each function it appears in
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: #include <winsock2.h>
 4: #include <windows.h>
 5: 
 6: /*top*/
 7: extern int t(void);
 8: int main(int argc, char **argv)
 9: {
10:   if (argc > 1000000) {
11:     printf("%p", &t);
12:   }
13: 
14:   return 0;
15: }
16: int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_wait_for_single_fd; return !p; }
/* end */

"x86_64-w64-mingw32-gcc -o conftest.exe -IC:/Ruby25-x64/include/ruby-2.5.0/x64-mingw32 -IC:/Ruby25-x64/include/ruby-2.5.0/ruby/backward -IC:/Ruby25-x64/include/ruby-2.5.0 -I. -I/usr/local/opt/openssl/include -D_FORTIFY_SOURCE=2 -D__USE_MINGW_ANSI_STDIO=1 -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64  -O3 -fno-fast-math conftest.c  -L. -LC:/Ruby25-x64/lib -L/usr/local/opt/openssl/lib -L. -pipe -s     -lx64-msvcrt-ruby250  -lgmp -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi  "
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: #include <winsock2.h>
 4: #include <windows.h>
 5: 
 6: /*top*/
 7: extern int t(void);
 8: int main(int argc, char **argv)
 9: {
10:   if (argc > 1000000) {
11:     printf("%p", &t);
12:   }
13: 
14:   return 0;
15: }
16: extern void rb_wait_for_single_fd();
17: int t(void) { rb_wait_for_single_fd(); return 0; }
/* end */

--------------------

find_library: checking for -lmysqlclient... -------------------- no

"x86_64-w64-mingw32-gcc -o conftest.exe -IC:/Ruby25-x64/include/ruby-2.5.0/x64-mingw32 -IC:/Ruby25-x64/include/ruby-2.5.0/ruby/backward -IC:/Ruby25-x64/include/ruby-2.5.0 -I. -I/usr/local/include -I/usr/local/opt/openssl/include -D_FORTIFY_SOURCE=2 -D__USE_MINGW_ANSI_STDIO=1 -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64  -O3 -fno-fast-math conftest.c  -L. -LC:/Ruby25-x64/lib -L/usr/local/lib -L/usr/local/opt/openssl/lib -L. -pipe -s     -lx64-msvcrt-ruby250 -lmysqlclient  -lgmp -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi  "
C:/Ruby25-x64/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lmysqlclient
collect2.exe: error: ld returned 1 exit status
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: #include <winsock2.h>
 4: #include <windows.h>
 5: 
 6: /*top*/
 7: extern int t(void);
 8: int main(int argc, char **argv)
 9: {
10:   if (argc > 1000000) {
11:     printf("%p", &t);
12:   }
13: 
14:   return 0;
15: }
16: 
17: int t(void) { ; return 0; }
/* end */

"x86_64-w64-mingw32-gcc -o conftest.exe -IC:/Ruby25-x64/include/ruby-2.5.0/x64-mingw32 -IC:/Ruby25-x64/include/ruby-2.5.0/ruby/backward -IC:/Ruby25-x64/include/ruby-2.5.0 -I. -I/usr/local/include -I/usr/local/opt/openssl/include -D_FORTIFY_SOURCE=2 -D__USE_MINGW_ANSI_STDIO=1 -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64  -O3 -fno-fast-math conftest.c  -L. -LC:/Ruby25-x64/lib -L/usr/local/lib -L/usr/local/opt/openssl/lib -L. -pipe -s     -lx64-msvcrt-ruby250 -lmysqlclient  -lgmp -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi  "
C:/Ruby25-x64/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lmysqlclient
collect2.exe: error: ld returned 1 exit status
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: #include <winsock2.h>
 4: #include <windows.h>
 5: 
 6: /*top*/
 7: extern int t(void);
 8: int main(int argc, char **argv)
 9: {
10:   if (argc > 1000000) {
11:     printf("%p", &t);
12:   }
13: 
14:   return 0;
15: }
16: 
17: int t(void) { ; return 0; }
/* end */

"x86_64-w64-mingw32-gcc -o conftest.exe -IC:/Ruby25-x64/include/ruby-2.5.0/x64-mingw32 -IC:/Ruby25-x64/include/ruby-2.5.0/ruby/backward -IC:/Ruby25-x64/include/ruby-2.5.0 -I. -I/usr/local/include -I/usr/local/opt/openssl/include -D_FORTIFY_SOURCE=2 -D__USE_MINGW_ANSI_STDIO=1 -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64  -O3 -fno-fast-math conftest.c  -L. -LC:/Ruby25-x64/lib -L/usr/local/lib -L/usr/local/opt/openssl/lib -L/usr/local/lib/mysql -L. -pipe -s     -lx64-msvcrt-ruby250 -lmysqlclient  -lgmp -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi  "
C:/Ruby25-x64/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lmysqlclient
collect2.exe: error: ld returned 1 exit status
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: #include <winsock2.h>
 4: #include <windows.h>
 5: 
 6: /*top*/
 7: extern int t(void);
 8: int main(int argc, char **argv)
 9: {
10:   if (argc > 1000000) {
11:     printf("%p", &t);
12:   }
13: 
14:   return 0;
15: }
16: 
17: int t(void) { ; return 0; }
/* end */

--------------------
相关问题