问题描述
我在 Rails v3.2.22.5 上运行 Ruby v2.3.5,但无法在 ubuntu 20.04 上安装 MysqL2 v0.3.20
我不断收到 "Failed to build gem extension"
错误。
nb:选择的版本都是项目所必需的,所以我无法更改它们。
关于如何最好地进行的任何想法?我已经尝试安装更高版本的 MysqL2 版本(例如 0.5.x),它安装得很好,但我当前的项目要避免这种情况。
不需要更新 rails 或 MysqL2 的解决方案将是理想的。
在我的 Gemfile 中是 gem 'MysqL2','0.3.20'
接下来我运行 gem install MysqL2 -v '0.3.20' --source 'https://rubygems.org/'
返回:
Building native extensions. This Could take a while...
ERROR: Error installing MysqL2:
ERROR: Failed to build gem native extension.
current directory: /home/t480s/.rbenv/versions/2.3.5/lib/ruby/gems/2.3.0/gems/MysqL2-0.3.20/ext/MysqL2
/home/t480s/.rbenv/versions/2.3.5/bin/ruby -r ./siteconf20210222-108873-10f37yb.rb 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()... no
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
-----
Using MysqL_config at /usr/bin/MysqL_config
-----
checking for MysqL.h... yes
checking for errmsg.h... yes
checking for MysqLd_error.h... yes
-----
Setting libpath to /usr/lib/x86_64-linux-gnu
-----
creating Makefile
To see why this extension Failed to compile,please check the mkmf.log which can be found here:
/home/t480s/.rbenv/versions/2.3.5/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0-static/MysqL2-0.3.20/mkmf.log
current directory: /home/t480s/.rbenv/versions/2.3.5/lib/ruby/gems/2.3.0/gems/MysqL2-0.3.20/ext/MysqL2
make "DESTDIR=" clean
current directory: /home/t480s/.rbenv/versions/2.3.5/lib/ruby/gems/2.3.0/gems/MysqL2-0.3.20/ext/MysqL2
make "DESTDIR="
compiling infile.c
compiling result.c
result.c: In function ‘msec_char_to_uint’:
result.c:189:17: warning: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare]
189 | for (i = 0; i < (len - 1); i++) {
| ^
result.c: In function ‘rb_MysqL_result_fetch_row’:
result.c:259:14: warning: this statement may fall through [-Wimplicit-fallthrough=]
259 | if (castBool && fields[i].length == 1) {
| ^
result.c:263:9: note: here
263 | case MysqL_TYPE_SHORT: /* SMALLINT field */
| ^~~~
compiling client.c
client.c: In function ‘nogvl_read_query_result’:
client.c:439:3: error: unkNown type name ‘my_bool’; did you mean ‘bool’?
439 | my_bool res = MysqL_read_query_result(client);
| ^~~~~~~
| bool
client.c: In function ‘_MysqL_client_options’:
client.c:775:3: error: unkNown type name ‘my_bool’; did you mean ‘bool’?
775 | my_bool boolval;
| ^~~~~~~
| bool
client.c:810:10: error: ‘MysqL_SECURE_AUTH’ undeclared (first use in this function); did you mean ‘MysqL_DEFAULT_AUTH’?
810 | case MysqL_SECURE_AUTH:
| ^~~~~~~~~~~~~~~~~
| MysqL_DEFAULT_AUTH
client.c:810:10: note: each undeclared identifier is reported only once for each function it appears in
client.c: In function ‘set_secure_auth’:
client.c:1198:38: error: ‘MysqL_SECURE_AUTH’ undeclared (first use in this function); did you mean ‘MysqL_DEFAULT_AUTH’?
1198 | return _MysqL_client_options(self,MysqL_SECURE_AUTH,value);
| ^~~~~~~~~~~~~~~~~
| MysqL_DEFAULT_AUTH
client.c:1199:1: warning: control reaches end of non-void function [-Wreturn-type]
1199 | }
| ^
make: *** [Makefile:239: client.o] Error 1
make Failed,exit code 2
have_header: checking for ruby/thread.h... -------------------- yes
"gcc -o conftest -I/home/t480s/.rbenv/versions/2.3.5/include/ruby-2.3.0/x86_64-linux -I/home/t480s/.rbenv/versions/2.3.5/include/ruby-2.3.0/ruby/backward -I/home/t480s/.rbenv/versions/2.3.5/include/ruby-2.3.0 -I. -I/home/t480s/.rbenv/versions/2.3.5/include -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat conftest.c -L. -L/home/t480s/.rbenv/versions/2.3.5/lib -Wl,-rpath,/home/t480s/.rbenv/versions/2.3.5/lib -L. -L/home/t480s/.rbenv/versions/2.3.5/lib -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,/home/t480s/.rbenv/versions/2.3.5/lib -L/home/t480s/.rbenv/versions/2.3.5/lib -lruby-static -lpthread -ldl -lcrypt -lm -lc"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc,char **argv)
4: {
5: return 0;
6: }
/* end */
"gcc -E -I/home/t480s/.rbenv/versions/2.3.5/include/ruby-2.3.0/x86_64-linux -I/home/t480s/.rbenv/versions/2.3.5/include/ruby-2.3.0/ruby/backward -I/home/t480s/.rbenv/versions/2.3.5/include/ruby-2.3.0 -I. -I/home/t480s/.rbenv/versions/2.3.5/include -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat conftest.c -o conftest.i"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <ruby/thread.h>
/* end */
--------------------
have_func: checking for rb_thread_call_without_gvl() in ruby/thread.h... -------------------- yes
"gcc -o conftest -I/home/t480s/.rbenv/versions/2.3.5/include/ruby-2.3.0/x86_64-linux -I/home/t480s/.rbenv/versions/2.3.5/include/ruby-2.3.0/ruby/backward -I/home/t480s/.rbenv/versions/2.3.5/include/ruby-2.3.0 -I. -I/home/t480s/.rbenv/versions/2.3.5/include -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat conftest.c -L. -L/home/t480s/.rbenv/versions/2.3.5/lib -Wl,/home/t480s/.rbenv/versions/2.3.5/lib -L/home/t480s/.rbenv/versions/2.3.5/lib -lruby-static -lpthread -ldl -lcrypt -lm -lc"
conftest.c: In function ‘t’:
conftest.c:15:43: warning: cast between incompatible function types from ‘void * (*)(void * (*)(void *),void *,void (*)(void *),void *)’ to ‘void (*)()’ [-Wcast-function-type]
15 | int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_thread_call_without_gvl; return !p; }
| ^
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <ruby/thread.h>
4:
5: /*toP*/
6: extern int t(void);
7: int main(int argc,char **argv)
8: {
9: if (argc > 1000000) {
10: printf("%p",&t);
11: }
12:
13: return 0;
14: }
15: int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_thread_call_without_gvl; return !p; }
/* end */
--------------------
have_func: checking for rb_thread_blocking_region()... -------------------- no
"gcc -o conftest -I/home/t480s/.rbenv/versions/2.3.5/include/ruby-2.3.0/x86_64-linux -I/home/t480s/.rbenv/versions/2.3.5/include/ruby-2.3.0/ruby/backward -I/home/t480s/.rbenv/versions/2.3.5/include/ruby-2.3.0 -I. -I/home/t480s/.rbenv/versions/2.3.5/include -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat conftest.c -L. -L/home/t480s/.rbenv/versions/2.3.5/lib -Wl,/home/t480s/.rbenv/versions/2.3.5/lib -L/home/t480s/.rbenv/versions/2.3.5/lib -lruby-static -lpthread -ldl -lcrypt -lm -lc"
conftest.c: In function ‘t’:
conftest.c:13:57: error: ‘rb_thread_blocking_region’ undeclared (first use in this function)
13 | int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_thread_blocking_region; return !p; }
| ^~~~~~~~~~~~~~~~~~~~~~~~~
conftest.c:13: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: /*toP*/
4: extern int t(void);
5: int main(int argc,char **argv)
6: {
7: if (argc > 1000000) {
8: printf("%p",&t);
9: }
10:
11: return 0;
12: }
13: int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_thread_blocking_region; return !p; }
/* end */
"gcc -o conftest -I/home/t480s/.rbenv/versions/2.3.5/include/ruby-2.3.0/x86_64-linux -I/home/t480s/.rbenv/versions/2.3.5/include/ruby-2.3.0/ruby/backward -I/home/t480s/.rbenv/versions/2.3.5/include/ruby-2.3.0 -I. -I/home/t480s/.rbenv/versions/2.3.5/include -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat conftest.c -L. -L/home/t480s/.rbenv/versions/2.3.5/lib -Wl,/home/t480s/.rbenv/versions/2.3.5/lib -L/home/t480s/.rbenv/versions/2.3.5/lib -lruby-static -lpthread -ldl -lcrypt -lm -lc"
/usr/bin/ld: /tmp/ccHlC1Zv.o: in function `t':
/home/t480s/.rbenv/versions/2.3.5/lib/ruby/gems/2.3.0/gems/MysqL2-0.3.20/ext/MysqL2/conftest.c:14: undefined reference to `rb_thread_blocking_region'
collect2: error: ld returned 1 exit status
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*toP*/
4: extern int t(void);
5: int main(int argc,&t);
9: }
10:
11: return 0;
12: }
13: extern void rb_thread_blocking_region();
14: int t(void) { rb_thread_blocking_region(); return 0; }
/* end */
--------------------
have_func: checking for rb_wait_for_single_fd()... -------------------- yes
"gcc -o conftest -I/home/t480s/.rbenv/versions/2.3.5/include/ruby-2.3.0/x86_64-linux -I/home/t480s/.rbenv/versions/2.3.5/include/ruby-2.3.0/ruby/backward -I/home/t480s/.rbenv/versions/2.3.5/include/ruby-2.3.0 -I. -I/home/t480s/.rbenv/versions/2.3.5/include -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat conftest.c -L. -L/home/t480s/.rbenv/versions/2.3.5/lib -Wl,/home/t480s/.rbenv/versions/2.3.5/lib -L/home/t480s/.rbenv/versions/2.3.5/lib -lruby-static -lpthread -ldl -lcrypt -lm -lc"
conftest.c: In function ‘t’:
conftest.c:13:57: error: ‘rb_wait_for_single_fd’ undeclared (first use in this function)
13 | int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_wait_for_single_fd; return !p; }
| ^~~~~~~~~~~~~~~~~~~~~
conftest.c:13: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: /*toP*/
4: extern int t(void);
5: int main(int argc,&t);
9: }
10:
11: return 0;
12: }
13: int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_wait_for_single_fd; return !p; }
/* end */
"gcc -o conftest -I/home/t480s/.rbenv/versions/2.3.5/include/ruby-2.3.0/x86_64-linux -I/home/t480s/.rbenv/versions/2.3.5/include/ruby-2.3.0/ruby/backward -I/home/t480s/.rbenv/versions/2.3.5/include/ruby-2.3.0 -I. -I/home/t480s/.rbenv/versions/2.3.5/include -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat conftest.c -L. -L/home/t480s/.rbenv/versions/2.3.5/lib -Wl,/home/t480s/.rbenv/versions/2.3.5/lib -L/home/t480s/.rbenv/versions/2.3.5/lib -lruby-static -lpthread -ldl -lcrypt -lm -lc"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*toP*/
4: extern int t(void);
5: int main(int argc,&t);
9: }
10:
11: return 0;
12: }
13: extern void rb_wait_for_single_fd();
14: int t(void) { rb_wait_for_single_fd(); return 0; }
/* end */
--------------------
have_func: checking for rb_hash_dup()... -------------------- yes
"gcc -o conftest -I/home/t480s/.rbenv/versions/2.3.5/include/ruby-2.3.0/x86_64-linux -I/home/t480s/.rbenv/versions/2.3.5/include/ruby-2.3.0/ruby/backward -I/home/t480s/.rbenv/versions/2.3.5/include/ruby-2.3.0 -I. -I/home/t480s/.rbenv/versions/2.3.5/include -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat conftest.c -L. -L/home/t480s/.rbenv/versions/2.3.5/lib -Wl,/home/t480s/.rbenv/versions/2.3.5/lib -L/home/t480s/.rbenv/versions/2.3.5/lib -lruby-static -lpthread -ldl -lcrypt -lm -lc"
conftest.c: In function ‘t’:
conftest.c:13:43: warning: cast between incompatible function types from ‘VALUE (*)(VALUE)’ {aka ‘long unsigned int (*)(long unsigned int)’} to ‘void (*)()’ [-Wcast-function-type]
13 | int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_hash_dup; return !p; }
| ^
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*toP*/
4: extern int t(void);
5: int main(int argc,&t);
9: }
10:
11: return 0;
12: }
13: int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_hash_dup; return !p; }
/* end */
--------------------
have_func: checking for rb_intern3()... -------------------- yes
"gcc -o conftest -I/home/t480s/.rbenv/versions/2.3.5/include/ruby-2.3.0/x86_64-linux -I/home/t480s/.rbenv/versions/2.3.5/include/ruby-2.3.0/ruby/backward -I/home/t480s/.rbenv/versions/2.3.5/include/ruby-2.3.0 -I. -I/home/t480s/.rbenv/versions/2.3.5/include -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat conftest.c -L. -L/home/t480s/.rbenv/versions/2.3.5/lib -Wl,/home/t480s/.rbenv/versions/2.3.5/lib -L/home/t480s/.rbenv/versions/2.3.5/lib -lruby-static -lpthread -ldl -lcrypt -lm -lc"
conftest.c: In function ‘t’:
conftest.c:13:57: error: ‘rb_intern3’ undeclared (first use in this function); did you mean ‘rb_intern2’?
13 | int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_intern3; return !p; }
| ^~~~~~~~~~
| rb_intern2
conftest.c:13: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: /*toP*/
4: extern int t(void);
5: int main(int argc,&t);
9: }
10:
11: return 0;
12: }
13: int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_intern3; return !p; }
/* end */
"gcc -o conftest -I/home/t480s/.rbenv/versions/2.3.5/include/ruby-2.3.0/x86_64-linux -I/home/t480s/.rbenv/versions/2.3.5/include/ruby-2.3.0/ruby/backward -I/home/t480s/.rbenv/versions/2.3.5/include/ruby-2.3.0 -I. -I/home/t480s/.rbenv/versions/2.3.5/include -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat conftest.c -L. -L/home/t480s/.rbenv/versions/2.3.5/lib -Wl,&t);
9: }
10:
11: return 0;
12: }
13: extern void rb_intern3();
14: int t(void) { rb_intern3(); return 0; }
/* end */
--------------------
have_header: checking for MysqL.h... -------------------- yes
"gcc -E -I/home/t480s/.rbenv/versions/2.3.5/include/ruby-2.3.0/x86_64-linux -I/home/t480s/.rbenv/versions/2.3.5/include/ruby-2.3.0/ruby/backward -I/home/t480s/.rbenv/versions/2.3.5/include/ruby-2.3.0 -I. -I/usr/include/MysqL -I/home/t480s/.rbenv/versions/2.3.5/include -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat conftest.c -o conftest.i"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <MysqL.h>
/* end */
--------------------
have_header: checking for errmsg.h... -------------------- yes
"gcc -E -I/home/t480s/.rbenv/versions/2.3.5/include/ruby-2.3.0/x86_64-linux -I/home/t480s/.rbenv/versions/2.3.5/include/ruby-2.3.0/ruby/backward -I/home/t480s/.rbenv/versions/2.3.5/include/ruby-2.3.0 -I. -I/usr/include/MysqL -I/home/t480s/.rbenv/versions/2.3.5/include -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat conftest.c -o conftest.i"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <errmsg.h>
/* end */
--------------------
have_header: checking for MysqLd_error.h... -------------------- yes
"gcc -E -I/home/t480s/.rbenv/versions/2.3.5/include/ruby-2.3.0/x86_64-linux -I/home/t480s/.rbenv/versions/2.3.5/include/ruby-2.3.0/ruby/backward -I/home/t480s/.rbenv/versions/2.3.5/include/ruby-2.3.0 -I. -I/usr/include/MysqL -I/home/t480s/.rbenv/versions/2.3.5/include -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat conftest.c -o conftest.i"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <MysqLd_error.h>
/* end */
--------------------
"gcc -o conftest -I/home/t480s/.rbenv/versions/2.3.5/include/ruby-2.3.0/x86_64-linux -I/home/t480s/.rbenv/versions/2.3.5/include/ruby-2.3.0/ruby/backward -I/home/t480s/.rbenv/versions/2.3.5/include/ruby-2.3.0 -I. -I/usr/include/MysqL -I/home/t480s/.rbenv/versions/2.3.5/include -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat conftest.c -L. -L/home/t480s/.rbenv/versions/2.3.5/lib -Wl,-export-dynamic -L/usr/lib/x86_64-linux-gnu -lMysqLclient -lpthread -lz -lm -lrt -lssl -lcrypto -ldl -lresolv -Wl,/home/t480s/.rbenv/versions/2.3.5/lib -L/home/t480s/.rbenv/versions/2.3.5/lib -lruby-static -Wall -funroll-loops -lpthread -ldl -lcrypt -lm -lc"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main() {return 0;}
/* end */
关于如何最好地进行的任何想法?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)