Forum: Ruby on Rails An error occured while installing mysql2 (0.3.11), and Bundler cannot continue.

Posted by Alaskayun@gmail.com (Guest)
on 2012-02-09 12:22
(Received via mailing list)
error information occurred when I execute "rails new demo1 --
database=mysql"

MY environment below:
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
readline 6.2
mysql (2.8.1)

Please help me, thx!

more detail message as follows:

Installing mysql2 (0.3.11) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native
extension.

        /opt/local/bin/ruby extconf.rb
checking for rb_thread_blocking_region()... no
checking for rb_wait_for_single_fd()... no
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
creating Makefile

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


Gem files will remain installed in /opt/local/lib/ruby/gems/1.8/gems/
mysql2-0.3.11 for inspection.
Results logged to /opt/local/lib/ruby/gems/1.8/gems/mysql2-0.3.11/ext/
mysql2/gem_make.out
An error occured while installing mysql2 (0.3.11), and Bundler cannot
continue.
Make sure that `gem install mysql2 -v '0.3.11'` succeeds before
bundling.
Posted by Colin Law (Guest)
on 2012-02-09 14:41
(Received via mailing list)
On 8 February 2012 12:59, Alaskayun@gmail.com <alaskayun@gmail.com> 
wrote:
> mysql (2.8.1)
>
> Please help me, thx!
>
> more detail message as follows:
>
> Installing mysql2 (0.3.11) with native extensions
> Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native
> extension.

I am just answering as no one else has, I don't know about Macs so
don't know the exact solution, but usually this sort of error is
caused by some development tool or library that is not installed or is
the wrong version.  If you were following a set of instructions for
installing on the Mac then maybe you have missed installing something.
 If you weren't then possibly you can find some to follow.

Colin

> /usr/bin/gcc-4.0 -I. -I. -I/opt/local/lib/ruby/1.8/i686-darwin8 -I. -
> opt/local/include/mysql5/mysql -fPIC  -D_P1003_1B_VISIBLE -
> DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -
> collect2: ld returned 1 exit status
> bundling.
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscribe@googlegroups.com.
> For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.
>



--
gplus.to/clanlaw
Posted by qian alaska (Guest)
on 2012-02-10 07:47
(Received via mailing list)
Hi Colin,

Thank your answer! I think you are right.  I will recompile mysql with
source package, and assign the directory of "lib,include,config" when 
the
gem package installs.

Thank you again!



2012/2/9 Colin Law <clanlaw@googlemail.com>
Posted by Edson Carlos C. (edsoncarlos_c)
on 2012-11-09 02:25
problem solve, type this command

sudo apt-get install libmysqlclient-dev

sudo apt-get install mysql

then run gem install mysql2
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.