Ruby Forum Ruby on Rails > MySQL Installation Issues

Posted by pete (Guest)
on 29.11.2007 18:33
(Received via mailing list)
Hello-

Trying to get rails up and running on my linux box with mysql.  When I
try to install the mysql gem, I get the following:

Building native extensions.  This could take a while...
ERROR:  While executing gem ... (Gem::Installer::ExtensionBuildError)
    ERROR: Failed to build gem native extension.

ruby extconf.rb install mysql
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... yes
checking for mysql_query() in -lmysqlclient... no
*** 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
        --without-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=/usr/local/bin/ruby
        --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
        --with-mlib
        --without-mlib
        --with-mysqlclientlib
        --without-mysqlclientlib
        --with-zlib
        --without-zlib
        --with-mysqlclientlib
        --without-mysqlclientlib
        --with-socketlib
        --without-socketlib
        --with-mysqlclientlib
        --without-mysqlclientlib
        --with-nsllib
        --without-nsllib
        --with-mysqlclientlib
        --without-mysqlclientlib


Gem files will remain installed in /usr/local/lib/ruby/gems/1.8/gems/
mysql-2.7 for inspection.
Results logged to /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7/
gem_make.out

I've tried setting the config option and other various things when
running 'gem install'.

Anyone know how to get around this?  Thanks very much.
Posted by Greg Donald (destiney)
on 29.11.2007 18:40
(Received via mailing list)
On Nov 29, 2007 11:32 AM, pete <peterbattaglia@gmail.com> wrote:
> Trying to get rails up and running on my linux box with mysql.  When I
> try to install the mysql gem, I get the following:
>
> Building native extensions.  This could take a while...
> ERROR:  While executing gem ... (Gem::Installer::ExtensionBuildError)
>     ERROR: Failed to build gem native extension.

cd /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7
gem install mysql -- 
--with-mysql-config=/usr/local/mysql/bin/mysql_config


--
Greg Donald
http://destiney.com/
Posted by pete (Guest)
on 29.11.2007 18:49
(Received via mailing list)
Thanks for the quick response.

No success with that either:

Building native extensions.  This could take a while...
ERROR:  While executing gem ... (Gem::Installer::ExtensionBuildError)
    ERROR: Failed to build gem native extension.

ruby extconf.rb install mysql -- --with-mysql-config=/usr/local/mysql/
bin/mysql_config
extconf.rb:1: command not found: /usr/local/mysql/bin/mysql_config --
cflags
*** 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
        --without-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=/usr/local/bin/ruby
        --with-mysql-config


Gem files will remain installed in /usr/local/lib/ruby/gems/1.8/gems/
mysql-2.7 for inspection.
Results logged to /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7/
gem_make.out
Posted by pete (Guest)
on 30.11.2007 17:06
(Received via mailing list)
This is still not working and I have tried almost every configuration
option possible.

As a side question...when you run 'gem install mysql', what exactly
does this do?

Does it create a binding to an already installed version of MySQL?
Does it install MySQL??

Thanks!
Posted by William Pratt (Guest)
on 30.11.2007 17:19
(Received via mailing list)
It compiles and installs a mysql driver used by ruby. You must have a
previously installed version of mysql including headers and libraries.

-Bill

pete wrote:
>
>> ruby extconf.rb install mysql -- --with-mysql-config=/usr/local/mysql/
>>         --without-opt-dir
>>
>>>> Trying to get rails up and running on my linux box with mysql.  When I
>>> Greg Donaldhttp://destiney.com/
>>>       
> >
>   

--
Sincerely,

William Pratt
Posted by pete (Guest)
on 30.11.2007 17:23
(Received via mailing list)
Thanks Bill.

Is there a dependency on the version of MySQL, I believe I am running
an older version.
Posted by William Pratt (Guest)
on 30.11.2007 17:44
(Received via mailing list)
It should work ok with 4.1or 5, but if I remember right, it recommends
5. I am using the latest 5 with no problems (5.0.45 I think).

-Bill

pete wrote:
>> -Bill
>>>       
>>>>         
>>>> necessary libraries and/or headers.  Check the mkmf.log file for more
>>>>         --without-make-prog
>>>> On Nov 29, 10:40 am, "Greg Donald" <gdon...@gmail.com> wrote:
>>>>> cd /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7
> >
>   

--
Sincerely,

William Pratt
Posted by pete (Guest)
on 30.11.2007 18:12
(Received via mailing list)
What about MySQL client?  I don't believe the client is installed,
only the server.
Posted by William Pratt (Guest)
on 30.11.2007 18:35
(Received via mailing list)
It's very possible that it is looking for libmysqlclient (I am almost
positive it does). Install the client / client libs and see if that
solves your problem.

-Bill

pete wrote:
>>
>>>> It compiles and installs a mysql driver used by ruby. You must have a
>>>>> does this do?
>>>>>> No success with that either:
>>>>>> Could not create Makefile due to some reason, probably lack of
>>>>>>         --with-make-prog
>>>>>>             
>>>>>>>>                 
>>>>         
>> --
>> Sincerely,
>>
>> William Pratt
>>     
> >
>   

--
Sincerely,

William Pratt
Posted by Scott Hodson (shodson)
on 14.01.2008 03:54
Greg Donald wrote:
> On Nov 29, 2007 11:32 AM, pete <peterbattaglia@gmail.com> wrote:
>> Trying to get rails up and running on my linux box with mysql.  When I
>> try to install the mysql gem, I get the following:
>>
>> Building native extensions.  This could take a while...
>> ERROR:  While executing gem ... (Gem::Installer::ExtensionBuildError)
>>     ERROR: Failed to build gem native extension.
> 
> cd /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7
> gem install mysql -- 
> --with-mysql-config=/usr/local/mysql/bin/mysql_config
> 
> 
> --
> Greg Donald
> http://destiney.com/

This fixed worked for me on OS X Tiger.  Thanks!  I have MySQL 5.0.45 
installed along with the MySQL GUI tools.
Posted by Wainer Moschetta (wainer)
on 26.01.2009 14:23
I was facing this same issue. I just installed libmysqlclient15-dev on
my syste (ubuntu 8.10) and could get gem mysql installed successfully

William Pratt wrote:
> It's very possible that it is looking for libmysqlclient (I am almost
> positive it does). Install the client / client libs and see if that
> solves your problem.
> 
> -Bill
> 
Posted by Abraham Tio (jazzhammer)
on 01.04.2009 20:26
> cd /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7
> gem install mysql -- 
> --with-mysql-config=/usr/local/mysql/bin/mysql_config
> Greg Donald
> http://destiney.com/

YUP. this works.
Posted by John Fatz (johnfatz)
on 05.04.2009 08:02
This worked for me also.


Wainer Moschetta wrote:
> I was facing this same issue. I just installed libmysqlclient15-dev on
> my syste (ubuntu 8.10) and could get gem mysql installed successfully
> 
> William Pratt wrote:
>> It's very possible that it is looking for libmysqlclient (I am almost
>> positive it does). Install the client / client libs and see if that
>> solves your problem.
>> 
>> -Bill
>> 
Posted by Greg Tucker (gatmac)
on 05.05.2009 01:14
Greg Donald wrote:
> On Nov 29, 2007 11:32 AM, pete <peterbattaglia@gmail.com> wrote:
>> Trying to get rails up and running on my linux box with mysql.  When I
>> try to install the mysql gem, I get the following:
>>
>> Building native extensions.  This could take a while...
>> ERROR:  While executing gem ... (Gem::Installer::ExtensionBuildError)
>>     ERROR: Failed to build gem native extension.
> 
> cd /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7
> gem install mysql -- 
> --with-mysql-config=/usr/local/mysql/bin/mysql_config
> 
> 
> --
> Greg Donald
> http://destiney.com/

This worked for me on Mac OS X Leopard with MySQL 5.1.34. In particular, 
the following command worked:

sudo gem install mysql -- 
--with-mysql-config=/usr/local/mysql/bin/mysql_config
Posted by Ni Pa (nipa)
on 03.06.2009 08:43
I tried:

<-- clip starts -->
[root]# gem install mysql -- --with-mysql-config=/usr/bin/mysql_config
Building native extensions.  This could take a while...
ERROR:  Error installing mysql:
        ERROR: Failed to build gem native extension.

/usr/local/bin/ruby extconf.rb install mysql -- 
--with-mysql-config=/usr/bin/mysql_config
checking for mysql_ssl_set()... no
checking for mysql.h... no
checking for mysql/mysql.h... no
*** 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
        --without-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=/usr/local/bin/ruby
        --with-mysql-config


Gem files will remain installed in 
/usr/local/lib/ruby/gems/1.8/gems/mysql-2.7 for inspection.
Results logged to 
/usr/local/lib/ruby/gems/1.8/gems/mysql-2.7/gem_make.out
<-- clip ends -->

Steps I needed on CentOS 5 linux were (in addition to installed 'normal' 
mysql)
1. Install mysql-devel "yum install mysql-devel" as root
2. Find the location of mysql_config "locate mysql_config" and fix that 
full path to "--with-mysql-config=" option
3. Success!

<-- clip starts -->
[root]# gem install mysql -- 
--with-mysql-config=/usr/lib/mysql/mysql_config
Building native extensions.  This could take a while...
Successfully installed mysql-2.7
1 gem installed
<-- clip ends -->
Posted by Third Replicator (Guest)
on 22.06.2009 09:37
(Received via mailing list)
I found a blog post that solves this problem ( http://nmanzi.com/?p=39
) and I turned it into a script so that you just have to run "./
install_mysql_ruby_adapter"

http://github.com/thirdreplicator/install_mysql_ruby_adapter_for_ruby1.9/tree/master

I run Ruby 1.9.1 on Ubuntu 8.04/8.10 and CentOS 5.2 with root
access.

David :)
Posted by Kirk Howard (kirkhoward)
on 06.08.2009 21:57
Whenever you can't build "native extensions", it means there is some lib 
or lib-dev missing.  Generally you'll need to do a sudo apt-get install 
lib-???-dev, or sudo apt-get install build_essential.

This time, I had to install the following:
'sudo apt-get install libmysqlclient15-dev'

Unfortunately, there is NO EASY WAY (that I know of) to identify what is 
missing from the attempt to compile.
Posted by Will Cain (willcain)
on 02.11.2009 00:12
Greg Donald wrote:
> cd /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7
> gem install mysql -- 
> --with-mysql-config=/usr/local/mysql/bin/mysql_config
> --
> Greg Donald
> http://destiney.com/

Worked for me too.
Posted by Henrique Gontijo (henriquegontijo)
on 07.02.2010 18:02
I got it working following these steps:

1. Install mysql-devel "yum install mysql-devel" as root
2. Find the location of mysql_config "locate mysql_config" and fix that
full path to "--with-mysql-config=" option
3. Success!

Best regards.
Posted by Roy Stannard (mamboze)
on 08.02.2010 15:34
Kirk Howard wrote:
> Whenever you can't build "native extensions", it means there is some lib 
> or lib-dev missing.  Generally you'll need to do a sudo apt-get install 
> lib-???-dev, or sudo apt-get install build_essential.
> 
> This time, I had to install the following:
> 'sudo apt-get install libmysqlclient15-dev'

Thanx this worked well tho the ri docs did not install (I think)

Terminal output:

Successfully installed mysql-2.8.1
1 gem installed
Installing ri documentation for mysql-2.8.1...

No definition for next_result

No definition for field_name

No definition for field_table

............

etc etc


Does this mean another file is missing and is not having ri docs any big 
deal?





Posted by Mike Montagne (mikemontagne)
on 21.03.2010 01:48
Abraham Tio wrote:
>> cd /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7
>> gem install mysql -- 
>> --with-mysql-config=/usr/local/mysql/bin/mysql_config
>> Greg Donald
>> http://destiney.com/
> 
> YUP. this works.

newbie question...

I was able to get an error free install on OSX Leopard 10.6.2 with the
following. The first cds to the mysql gem location of my Leopard install
(may differ for others):

cd /Library/Ruby/Gems/1.8/gems/mysql-2.8.1
sudo gem install mysql --no-rdoc --no-ri --
--with-mysql-config=/usr/local/mysql/bin/mysql_config

There were many "No definition for..." RDoc and Ri errors otherwise.

Just starting my first Ruby project... and not so comfortable with this
install of the mysql gem. I expect there's possibly serious
ramifications of excluding these two processes. Can anybody tell us what
are we missing by resorting to these install parameters; and/or how can
we install with ri and rdoc successfully?

tia

m
Posted by Colin Law (Guest)
on 21.03.2010 09:58
(Received via mailing list)
On 21 March 2010 00:48, Mike Montagne <lists@ruby-forum.com> wrote:
>
> Just starting my first Ruby project... and not so comfortable with this
> install of the mysql gem. I expect there's possibly serious
> ramifications of excluding these two processes. Can anybody tell us what
> are we missing by resorting to these install parameters; and/or how can
> we install with ri and rdoc successfully?

ri and rdoc are just for documentation of the gem.  Google them to
find details.  Not having them will not affect the operation of the
gem.

Colin
Posted by Mike Montagne (mikemontagne)
on 21.03.2010 19:42
Colin Law wrote:

> ri and rdoc are just for documentation of the gem.  Google them to
> find details.  Not having them will not affect the operation of the
> gem.
> 
> Colin

Thanks Colin. I quickly found that out. I've posted instructions for 
resolving this issue at MySQL:

http://forums.mysql.com/read.php?116,359591,359591#msg-359591

The described process determines vital paths for successful installation 
on potentially any system.
Posted by Jonny Huuan (huuan)
on 16.06.2010 08:21
Mike Montagne wrote:
> Abraham Tio wrote:
>>> cd /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7
>>> gem install mysql -- 
>>> --with-mysql-config=/usr/local/mysql/bin/mysql_config
>>> Greg Donald
>>> http://destiney.com/
>> 
>> YUP. this works.
> 
> newbie question...
> 
> I was able to get an error free install on OSX Leopard 10.6.2 with the
> following. The first cds to the mysql gem location of my Leopard install
> (may differ for others):
> 
> cd /Library/Ruby/Gems/1.8/gems/mysql-2.8.1
> sudo gem install mysql --no-rdoc --no-ri --
> --with-mysql-config=/usr/local/mysql/bin/mysql_config
> 
> There were many "No definition for..." RDoc and Ri errors otherwise.
> 
> Just starting my first Ruby project... and not so comfortable with this
> install of the mysql gem. I expect there's possibly serious
> ramifications of excluding these two processes. Can anybody tell us what
> are we missing by resorting to these install parameters; and/or how can
> we install with ri and rdoc successfully?
> 
> tia
> 
> m
Yay!
After much irc and googling, at last, I found your recent entry Mike and
 I also was able to get an error free install on OS X 10.6.3
with
$ sudo gem install mysql --no-rdoc --no-ri -- 
--with-mysql-config=/usr/local/mysql/bin/mysql_config

TX!
huuan