CentOS: Can't install mysql gem

350 views
Skip to first unread message

Guyren G Howe

unread,
Oct 29, 2009, 3:54:49 AM10/29/09
to sdr...@googlegroups.com
This seems like something I ought to be able to find on google, but
I've been at it for hours, and I can't find the solution.

I've got mysql and mysql-devel installed (v 5.0.77 64 bit) on CentOS 5.

I've installed all sorts of gems, but I get the below. Any thoughts?

gem install mysql -v 2.8.1 -- --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 --with-mysql-config=/usr/bin/mysql_config
checking for mysql_ssl_set()... no
checking for rb_str_set_len()... no
checking for rb_thread_start_timer()... 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.


mkmf.log has this:

find_library: checking for mysql_query() in -lmysqlclient...
-------------------- no

"gcc -o conftest -I. -I/usr/lib64/ruby/1.8/x86_64-linux -I. -I/usr/
local/include -O2 -g -m64 -mtune=generic -Wall -fPIC conftest.c -
L"." -L"/usr/lib64" -L"/usr/local/lib" -L. -rdynamic -Wl,-export-
dynamic -lruby-static -lmysqlclient -lpthread -ldl -lcrypt -lm -
lc"
conftest.c: In function ‘t’:
conftest.c:3: error: ‘mysql_query’ undeclared (first use in this
function)
conftest.c:3: error: (Each undeclared identifier is reported only once
conftest.c:3: error: for each function it appears in.)
checked program was:
/* begin */
1: /*top*/
2: int main() { return 0; }
3: int t() { void ((*volatile p)()); p = (void ((*)()))mysql_query;
return 0; }
/* end */

Steven Fines

unread,
Oct 29, 2009, 12:55:18 PM10/29/09
to sdr...@googlegroups.com
Guyren-
It looks like it can't find the mysql.h header file- you'll probably need check your include path for the G++ compiler.

make sure it shows in one of the paths in gcc -v or is explicitly set...


Now back to my regularly scheduled lurking.

SF
--

Ted Turner  - "Sports is like a war without the killing."

Jason King

unread,
Oct 29, 2009, 12:58:53 PM10/29/09
to sdr...@googlegroups.com
It will never work if it can't find mysql.h I'm wondering if you're
pointing to the right mysql_config.

Run:
/usr/bin/mysql_config --include

Then see if there's a mysql.h in the directory that is returned. If
not then my guess is that mysql-devel installed a different
mysql_config and you need to point to that so that it references the
right include location for the headers.

Guyren G Howe

unread,
Oct 30, 2009, 2:34:39 AM10/30/09
to sdr...@googlegroups.com
On Oct 29, 2009, at 9:58 , Jason King wrote:

> It will never work if it can't find mysql.h I'm wondering if you're
> pointing to the right mysql_config.
>
> Run:
> /usr/bin/mysql_config --include
>
> Then see if there's a mysql.h in the directory that is returned. If
> not then my guess is that mysql-devel installed a different
> mysql_config and you need to point to that so that it references the
> right include location for the headers.


Thanks, but that's not it:

[root@localhost tmp]# /usr/bin/mysql_config --include
-I/usr/include/mysql
[root@localhost tmp]# ls /usr/include/mysql
chardefs.h keymaps.h my_config.h my_global.h
mysql_com.h mysql_time.h readline.h sql_common.h
tilde.h
decimal.h m_ctype.h my_config_x86_64.h my_list.h
mysqld_ername.h mysql_version.h rlmbutil.h sql_state.h
typelib.h
errmsg.h m_string.h my_dbug.h my_net.h
mysqld_error.h my_sys.h rlprivate.h sslopt-case.h
xmalloc.h
history.h my_alloc.h my_dir.h my_no_pthread.h
mysql_embed.h my_xml.h rlshell.h sslopt-longopts.h
keycache.h my_attribute.h my_getopt.h my_pthread.h
mysql.h raid.h rltypedefs.h sslopt-vars.h


Regards,

Guyren G Howe
Relevant Logic LLC

guyren-at-relevantlogic.com ~ http://relevantlogic.com ~ +1 512 784 3178

Ruby/Rails, REALbasic, PHP programming
PostgreSQL, MySQL database design and consulting
Technical writing and training

Read my book, Real OOP with REALbasic: <http://relevantlogic.com/oop-book/about-the-oop-book.php
>

Josh Lubaway

unread,
Oct 30, 2009, 4:44:41 PM10/30/09
to sdr...@googlegroups.com
Not sure about CentOS but whenever I get an extconf.rb error in Ubuntu the fix is:

sudo apt-get install ruby<version>-dev

Again not sure if that will solve your problem on CentOS just throwing it out there (thinking out loud).

-Josh

Guyren G Howe

unread,
Oct 30, 2009, 5:06:34 PM10/30/09
to sdr...@googlegroups.com
On Oct 30, 2009, at 13:44 , Josh Lubaway wrote:

Not sure about CentOS but whenever I get an extconf.rb error in Ubuntu the fix is:

sudo apt-get install ruby<version>-dev

Again not sure if that will solve your problem on CentOS just throwing it out there (thinking out loud).

Thanks, but I have ruby-devel installed.

On Thu, Oct 29, 2009 at 11:34 PM, Guyren G Howe <guy...@gmail.com> wrote:

On Oct 29, 2009, at 9:58 , Jason King wrote:

> It will never work if it can't find mysql.h  I'm wondering if you're
> pointing to the right mysql_config.
>
> Run:
> /usr/bin/mysql_config --include
>
> Then see if there's a mysql.h in the directory that is returned.  If
> not then my guess is that mysql-devel installed a different
> mysql_config and you need to point to that so that it references the
> right include location for the headers.

I should add that I have tried both mysql_config files that I have, and I can't build with either of them.

Kerry Foley

unread,
Oct 30, 2009, 6:29:58 PM10/30/09
to sdr...@googlegroups.com
Guyren,
I had a problem installing the mysql gem after a Snow Leopard upgrade. I was getting an uninitialized mysql constant error. So, not your OS and a slightly different error I know. 

Anyway my problem was that I had previously done a "gem install" and had the mysql gem installed in /Users/<user>/.gem as well as on the system in /usr. Neither "gem uninstall" or "sudo gem uninstall" would get rid of the user copy, even though it showed up via "gem list". When I deleted it manually I was able to proceed with a fresh "sudo gem install ..." and everything compiled.....

When I was researching my problem I came across some people who had compile problems because the mysql library files were in /usr/local/mysql/lib instead of /usr/local/mysql/lib/mysql.  One of your errors was "checking for mysql/mysql.h... no" so it may be related.
This didn't fix anything for me but that issue can be solved by creating a link in /usr/local/mysql/lib for mysql:
"sudo ln -s . mysql"

Lastly, and you've probably done this already, but in Ubuntu you need to install the "build-essential" package to get the c/c++ header files for building native extensions. Unlikely to be your problem since it's mysql specific header info but in CentOS you might need to do:
yum groupinstall "Development Tools"
or maybe
yum install gcc gcc-c++ kernel-devel
or maybe
yum install buildsys-build

Hope that helps.
Regards,
Kerry

Gisborne

unread,
Oct 31, 2009, 12:51:06 AM10/31/09
to SD Ruby
On Oct 30, 3:29 pm, Kerry Foley <bonefish.fo...@gmail.com> wrote:
> Anyway my problem was that I had previously done a "gem install" and had
> the mysql gem installed in /Users/<user>/.gem as well as on the system
> in /usr. Neither "gem uninstall" or "sudo gem uninstall" would get rid
> of the user copy, even though it showed up via "gem list". When I
> deleted it manually I was able to proceed with a fresh "sudo gem install
> ..." and everything compiled.....

I don't think this is it: I don't see the gem in gem list --local.

> When I was researching my problem I came across some people who had
> compile problems because the mysql library files were in
> /usr/local/mysql/lib instead of /usr/local/mysql/lib/mysql.  One of your
> errors was "checking for mysql/mysql.h... no" so it may be related.
> This didn't fix anything for me but that issue can be solved by creating
> a link in /usr/local/mysql/lib for mysql:
> "sudo ln -s . mysql"

I don't think this is the issue; mysql_config is pointing at precisely
the right place.

> Lastly, and you've probably done this already, but in Ubuntu you need to
> install the "build-essential" package to get the c/c++ header files for
> building native extensions. Unlikely to be your problem since it's mysql
> specific header info but in CentOS you might need to do:
> yum groupinstall "Development Tools"
> or maybe
> yum install gcc gcc-c++ kernel-devel
> or maybe
> yum install buildsys-build

This I hadn't done, but it doesn't help.

One thing I haven't mentioned is that I'm using ruby-enterprise-1.8.6,
along with ruby-devel-1.8.6. I don't see a ruby-enterprise-devel
anywhere, and my understanding of Enterprise is that it's binary
compatible with ruby, so I think that's okay.

What sort of diagnostics might I perform to see why this is failing?

Nic Benders

unread,
Oct 31, 2009, 4:58:14 AM10/31/09
to sdr...@googlegroups.com, SD Ruby
You want to look in the gem extension's build directory for the actual
output file from "configure". When it is testing something like
"looking for mysql.h", what it is really doing is trying to compile a
very simple C program that uses "include <mysql.h>" or equivalent.
Although the "configure" program only outputs yes or no when it is
run, it will also generally leave a log with the actual compiler
error, and possibly the test code and command. With that you can
figure out if the Ruby setup is at fault, or if you have some other,
possibly unrelated compiler issue.

Guyren G Howe

unread,
Oct 31, 2009, 5:31:01 AM10/31/09
to sdr...@googlegroups.com
On Oct 31, 2009, at 1:58 , Nic Benders wrote:

> You want to look in the gem extension's build directory for the actual
> output file from "configure". When it is testing something like
> "looking for mysql.h", what it is really doing is trying to compile a
> very simple C program that uses "include <mysql.h>" or equivalent.
> Although the "configure" program only outputs yes or no when it is
> run, it will also generally leave a log with the actual compiler
> error, and possibly the test code and command. With that you can
> figure out if the Ruby setup is at fault, or if you have some other,
> possibly unrelated compiler issue.


Many thanks for your help.

But please define "the gem extension's build directory" and how I
determine what that is.

Cynthia Kiser

unread,
Nov 1, 2009, 12:54:32 PM11/1/09
to sdr...@googlegroups.com
Quoting Gisborne <guy...@gmail.com>:
> One thing I haven't mentioned is that I'm using ruby-enterprise-1.8.6,
> along with ruby-devel-1.8.6. I don't see a ruby-enterprise-devel
> anywhere, and my understanding of Enterprise is that it's binary
> compatible with ruby, so I think that's okay.

Where are you getting your ruby-enterprise-1.8.6 from? Did you compile
from source? The current REE is 1.8.7 and when compiling from the
script that comes in the tarball always builds the mysql gem as part
of the install (along with rails and pg gems). I don't recall having
issues with the mysql gem builds on my RHEL5 systems - but so far
those have all been 32 bit systems. I am about to try some 64 bit
systems so can report back if we have problems and what their
resolution is.

If building from the newest REE 1.8.7 source does not fix your install
issues, can you send more details of what mysql stuff you have
installed and how. e.g. are these the stock RHEL MySQL rpms or did you
install either from source or from third party rpms.

--
Cynthia Kiser
c...@caltech.edu

Guyren G Howe

unread,
Nov 3, 2009, 4:34:06 AM11/3/09
to sdr...@googlegroups.com
On Nov 1, 2009, at 9:54 , Cynthia Kiser wrote:

> Where are you getting your ruby-enterprise-1.8.6 from? Did you compile
> from source? The current REE is 1.8.7 and when compiling from the
> script that comes in the tarball always builds the mysql gem as part
> of the install (along with rails and pg gems). I don't recall having
> issues with the mysql gem builds on my RHEL5 systems - but so far
> those have all been 32 bit systems. I am about to try some 64 bit
> systems so can report back if we have problems and what their
> resolution is.
>
> If building from the newest REE 1.8.7 source does not fix your install
> issues, can you send more details of what mysql stuff you have
> installed and how. e.g. are these the stock RHEL MySQL rpms or did you
> install either from source or from third party rpms.


I installed ruby-enterprise from a rpm I downloaded from:

http://rpms.famillecollet.com/enterprise/remi-release-5.rpm

I guess I could try installing from source. But there's no obvious
reason why the source install of the mysql gem through the ruby-
enterprise source should work any better than what I'm trying to do
now. And just reinstalling ruby-enterprise a different way in case
that manages to work seems a bit like the sort of flailing about madly
in case something works that I'd rather avoid.

Is there no other suggestion about diagnostics I might perform on my
build process to determine why it's failing?

Adam Grant

unread,
Nov 3, 2009, 1:18:49 PM11/3/09
to sdr...@googlegroups.com
Hi Guyren,

I found some hints on a MySQL forum: (http://forums.mysql.com/read.php?116,178217,178217#msg-178217)

On my CentOS system, there are two mysql_configs: /usr/bin/mysql_config and /usr/lib/mysql/mysql_config

I would try the --with-mysql-config option with both, or whereever there are other mysql_config's. Since you are on 64 bit, maybe its:

gem install mysql -- --with-mysql-config=/usr/lib64/mysql/mysql_config

Also, the docs for the gem on http://www.tmtm.org/en/mysql/ruby/ show that there are a couple other params you can pass to extconf.rb:

Install

1st:

% ruby extconf.rb

or

% ruby extconf.rb --with-mysql-dir=/usr/local/mysql

or

% ruby extconf.rb --with-mysql-config

then

% make

extconf.rb has following options:

--with-mysql-include=dir
MySQL header file directory. Default is /usr/local/include.
--with-mysql-lib=dir
MySQL library directory. Default is /usr/local/lib.
--with-mysql-dir=dir
Same as --with-mysql-include=dir/include, --with-mysql-lib=dir/lib.
--with-mysql-config[=/path/to/mysql_config]
Get compile-parameter from mysql_config command.
I'm sure you've tried all these, but just in case :)
I've had problems too in the past, which were fixed either with a dev library or a client dev library. Sounds like you have them all though.

Good luck!

--
Adam Grant
Reply all
Reply to author
Forward
0 new messages