<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>rubyqian</title>
    <link>https://ruby-china.org/rubyqian</link>
    <description/>
    <language>en-us</language>
    <item>
      <title>求教：安装 mysql2 gem 0.3.11 版本出错</title>
      <description>&lt;p&gt;我的环境如下：
Mac OS 10.4.11,
Ruby  1.8.7
Rails 3.2.1,
Gem 1.8.15
数据库 mysql5  Ver 14.14 Distrib 5.1.61, for apple-darwin8.11.1 (i386) using
gem 包：
mysql (2.8.1)&lt;/p&gt;

&lt;p&gt;当我执行 rails new demo 命令时出现：&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Installing mysql2 &lt;span class="o"&gt;(&lt;/span&gt;0.3.11&lt;span class="o"&gt;)&lt;/span&gt; with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native
extension.

       /opt/local/bin/ruby extconf.rb
checking &lt;span class="k"&gt;for &lt;/span&gt;rb_thread_blocking_region&lt;span class="o"&gt;()&lt;/span&gt;... no
checking &lt;span class="k"&gt;for &lt;/span&gt;rb_wait_for_single_fd&lt;span class="o"&gt;()&lt;/span&gt;... no
checking &lt;span class="k"&gt;for &lt;/span&gt;mysql.h... &lt;span class="nb"&gt;yes
&lt;/span&gt;checking &lt;span class="k"&gt;for &lt;/span&gt;errmsg.h... &lt;span class="nb"&gt;yes
&lt;/span&gt;checking &lt;span class="k"&gt;for &lt;/span&gt;mysqld_error.h... &lt;span class="nb"&gt;yes
&lt;/span&gt;creating Makefile

make
/usr/bin/gcc-4.0 &lt;span class="nt"&gt;-I&lt;/span&gt;&lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="nt"&gt;-I&lt;/span&gt;&lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="nt"&gt;-I&lt;/span&gt;/opt/local/lib/ruby/1.8/i686-darwin8 &lt;span class="nt"&gt;-I&lt;/span&gt;&lt;span class="nb"&gt;.&lt;/span&gt; -
DHAVE_MYSQL_H &lt;span class="nt"&gt;-DHAVE_ERRMSG_H&lt;/span&gt; &lt;span class="nt"&gt;-DHAVE_MYSQLD_ERROR_H&lt;/span&gt; &lt;span class="nt"&gt;-I&lt;/span&gt;/opt/local/
include &lt;span class="nt"&gt;-D_XOPEN_SOURCE&lt;/span&gt; &lt;span class="nt"&gt;-D_DARWIN_C_SOURCE&lt;/span&gt;  &lt;span class="nt"&gt;-I&lt;/span&gt;/opt/local/include &lt;span class="nt"&gt;-I&lt;/span&gt;/
opt/local/include/mysql5/mysql  &lt;span class="nt"&gt;-fPIC&lt;/span&gt;    &lt;span class="nt"&gt;-D_P1003_1B_VISIBLE&lt;/span&gt; -
DSIGNAL_WITH_VIO_CLOSE &lt;span class="nt"&gt;-DSIGNALS_DONT_BREAK_READ&lt;/span&gt; -
DIGNORE_SIGHUP_SIGQUIT  &lt;span class="nt"&gt;-DDONT_DECLARE_CXA_PURE_VIRTUAL&lt;/span&gt; &lt;span class="nt"&gt;-fno-common&lt;/span&gt; -
O2 &lt;span class="nt"&gt;-arch&lt;/span&gt; i386  &lt;span class="nt"&gt;-fno-common&lt;/span&gt; &lt;span class="nt"&gt;-pipe&lt;/span&gt; &lt;span class="nt"&gt;-fno-common&lt;/span&gt;  &lt;span class="nt"&gt;-Wall&lt;/span&gt; &lt;span class="nt"&gt;-funroll-loops&lt;/span&gt; -
&lt;span class="nb"&gt;arch &lt;/span&gt;i386 &lt;span class="nt"&gt;-c&lt;/span&gt; client.c
/usr/bin/gcc-4.0 &lt;span class="nt"&gt;-I&lt;/span&gt;&lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="nt"&gt;-I&lt;/span&gt;&lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="nt"&gt;-I&lt;/span&gt;/opt/local/lib/ruby/1.8/i686-darwin8 &lt;span class="nt"&gt;-I&lt;/span&gt;&lt;span class="nb"&gt;.&lt;/span&gt; -
DHAVE_MYSQL_H &lt;span class="nt"&gt;-DHAVE_ERRMSG_H&lt;/span&gt; &lt;span class="nt"&gt;-DHAVE_MYSQLD_ERROR_H&lt;/span&gt; &lt;span class="nt"&gt;-I&lt;/span&gt;/opt/local/
include &lt;span class="nt"&gt;-D_XOPEN_SOURCE&lt;/span&gt; &lt;span class="nt"&gt;-D_DARWIN_C_SOURCE&lt;/span&gt;  &lt;span class="nt"&gt;-I&lt;/span&gt;/opt/local/include &lt;span class="nt"&gt;-I&lt;/span&gt;/
opt/local/include/mysql5/mysql  &lt;span class="nt"&gt;-fPIC&lt;/span&gt;    &lt;span class="nt"&gt;-D_P1003_1B_VISIBLE&lt;/span&gt; -
DSIGNAL_WITH_VIO_CLOSE &lt;span class="nt"&gt;-DSIGNALS_DONT_BREAK_READ&lt;/span&gt; -
DIGNORE_SIGHUP_SIGQUIT  &lt;span class="nt"&gt;-DDONT_DECLARE_CXA_PURE_VIRTUAL&lt;/span&gt; &lt;span class="nt"&gt;-fno-common&lt;/span&gt; -
O2 &lt;span class="nt"&gt;-arch&lt;/span&gt; i386  &lt;span class="nt"&gt;-fno-common&lt;/span&gt; &lt;span class="nt"&gt;-pipe&lt;/span&gt; &lt;span class="nt"&gt;-fno-common&lt;/span&gt;  &lt;span class="nt"&gt;-Wall&lt;/span&gt; &lt;span class="nt"&gt;-funroll-loops&lt;/span&gt; -
&lt;span class="nb"&gt;arch &lt;/span&gt;i386 &lt;span class="nt"&gt;-c&lt;/span&gt; mysql2_ext.c
./client.h:20: warning: ‘rb_thread_blocking_region’ defined but not
used
/usr/bin/gcc-4.0 &lt;span class="nt"&gt;-I&lt;/span&gt;&lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="nt"&gt;-I&lt;/span&gt;&lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="nt"&gt;-I&lt;/span&gt;/opt/local/lib/ruby/1.8/i686-darwin8 &lt;span class="nt"&gt;-I&lt;/span&gt;&lt;span class="nb"&gt;.&lt;/span&gt; -
DHAVE_MYSQL_H &lt;span class="nt"&gt;-DHAVE_ERRMSG_H&lt;/span&gt; &lt;span class="nt"&gt;-DHAVE_MYSQLD_ERROR_H&lt;/span&gt; &lt;span class="nt"&gt;-I&lt;/span&gt;/opt/local/
include &lt;span class="nt"&gt;-D_XOPEN_SOURCE&lt;/span&gt; &lt;span class="nt"&gt;-D_DARWIN_C_SOURCE&lt;/span&gt;  &lt;span class="nt"&gt;-I&lt;/span&gt;/opt/local/include &lt;span class="nt"&gt;-I&lt;/span&gt;/
opt/local/include/mysql5/mysql  &lt;span class="nt"&gt;-fPIC&lt;/span&gt;    &lt;span class="nt"&gt;-D_P1003_1B_VISIBLE&lt;/span&gt; -
DSIGNAL_WITH_VIO_CLOSE &lt;span class="nt"&gt;-DSIGNALS_DONT_BREAK_READ&lt;/span&gt; -
DIGNORE_SIGHUP_SIGQUIT  &lt;span class="nt"&gt;-DDONT_DECLARE_CXA_PURE_VIRTUAL&lt;/span&gt; &lt;span class="nt"&gt;-fno-common&lt;/span&gt; -
O2 &lt;span class="nt"&gt;-arch&lt;/span&gt; i386  &lt;span class="nt"&gt;-fno-common&lt;/span&gt; &lt;span class="nt"&gt;-pipe&lt;/span&gt; &lt;span class="nt"&gt;-fno-common&lt;/span&gt;  &lt;span class="nt"&gt;-Wall&lt;/span&gt; &lt;span class="nt"&gt;-funroll-loops&lt;/span&gt; -
&lt;span class="nb"&gt;arch &lt;/span&gt;i386 &lt;span class="nt"&gt;-c&lt;/span&gt; result.c
/usr/bin/gcc-4.0 &lt;span class="nt"&gt;-dynamic&lt;/span&gt; &lt;span class="nt"&gt;-bundle&lt;/span&gt; &lt;span class="nt"&gt;-undefined&lt;/span&gt; suppress &lt;span class="nt"&gt;-flat_namespace&lt;/span&gt; -
o mysql2.bundle client.o mysql2_ext.o result.o &lt;span class="nt"&gt;-L&lt;/span&gt;&lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="nt"&gt;-L&lt;/span&gt;/opt/local/lib &lt;span class="nt"&gt;-L&lt;/span&gt;/
opt/local/lib &lt;span class="nt"&gt;-L&lt;/span&gt;&lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="nt"&gt;-L&lt;/span&gt;/opt/local/lib &lt;span class="nt"&gt;-arch&lt;/span&gt; i386 &lt;span class="nt"&gt;-Wl&lt;/span&gt;,-rpath,/opt/local/
lib  &lt;span class="nt"&gt;-arch&lt;/span&gt; i386  &lt;span class="nt"&gt;-lruby&lt;/span&gt; &lt;span class="nt"&gt;-L&lt;/span&gt;/opt/local/lib   &lt;span class="nt"&gt;-L&lt;/span&gt;/opt/local/lib/mysql5/
mysql &lt;span class="nt"&gt;-lmysqlclient_r&lt;/span&gt; &lt;span class="nt"&gt;-L&lt;/span&gt;/opt/local/lib &lt;span class="nt"&gt;-lz&lt;/span&gt; &lt;span class="nt"&gt;-lm&lt;/span&gt;   &lt;span class="nt"&gt;-L&lt;/span&gt;/opt/local/lib/ -
lssl &lt;span class="nt"&gt;-lcrypto&lt;/span&gt;  &lt;span class="nt"&gt;-lpthread&lt;/span&gt; &lt;span class="nt"&gt;-ldl&lt;/span&gt; &lt;span class="nt"&gt;-lobjc&lt;/span&gt;
/usr/bin/ld: unknown flag: &lt;span class="nt"&gt;-rpath&lt;/span&gt;
collect2: ld returned 1 &lt;span class="nb"&gt;exit &lt;/span&gt;status
make: &lt;span class="k"&gt;***&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;mysql2.bundle] Error 1


Gem files will remain installed &lt;span class="k"&gt;in&lt;/span&gt; /opt/local/lib/ruby/gems/1.8/gems/
mysql2-0.3.11 &lt;span class="k"&gt;for &lt;/span&gt;inspection.
Results logged to /opt/local/lib/ruby/gems/1.8/gems/mysql2-0.3.11/ext/
mysql2/gem_make.out
An error occured &lt;span class="k"&gt;while &lt;/span&gt;installing mysql2 &lt;span class="o"&gt;(&lt;/span&gt;0.3.11&lt;span class="o"&gt;)&lt;/span&gt;, and Bundler cannot
&lt;span class="k"&gt;continue&lt;/span&gt;&lt;span class="nb"&gt;.&lt;/span&gt;
Make sure that &lt;span class="sb"&gt;`&lt;/span&gt;gem &lt;span class="nb"&gt;install &lt;/span&gt;mysql2 &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="s1"&gt;'0.3.11'&lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt; succeeds before
bundling.

&lt;/code&gt;&lt;/pre&gt;</description>
      <author>rubyqian</author>
      <pubDate>Thu, 09 Feb 2012 17:55:12 +0800</pubDate>
      <link>https://ruby-china.org/topics/1108</link>
      <guid>https://ruby-china.org/topics/1108</guid>
    </item>
  </channel>
</rss>
