mysql gem problems

I have Xcode 3.0+ installed

Ruby 1.9.2

And a direct dmg for mysql

$ sudo gem install mysql – --with-mysql-dir=/usr/local/mysql

Password:

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-dir=/usr/local/mysql

checking for mysql_ssl_set()… *** 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

/usr/local/lib/ruby/1.9.1/mkmf.rb:368:in `try_do’: The complier failed to generate an executable file. (RuntimeError)

You have to install development tools first.

from /usr/local/lib/ruby/1.9.1/mkmf.rb:435:in `try_link0'

from /usr/local/lib/ruby/1.9.1/mkmf.rb:440:in `try_link'

from /usr/local/lib/ruby/1.9.1/mkmf.rb:552:in `try_func'

from /usr/local/lib/ruby/1.9.1/mkmf.rb:797:in `block in have_func'

from /usr/local/lib/ruby/1.9.1/mkmf.rb:693:in `block in checking_for'

from /usr/local/lib/ruby/1.9.1/mkmf.rb:280:in `block (2 levels) in postpone'

from /usr/local/lib/ruby/1.9.1/mkmf.rb:254:in `open'

from /usr/local/lib/ruby/1.9.1/mkmf.rb:280:in `block in postpone'

from /usr/local/lib/ruby/1.9.1/mkmf.rb:254:in `open'

from /usr/local/lib/ruby/1.9.1/mkmf.rb:276:in `postpone'

from /usr/local/lib/ruby/1.9.1/mkmf.rb:692:in `checking_for'

from /usr/local/lib/ruby/1.9.1/mkmf.rb:796:in `have_func'

from extconf.rb:50:in `<main>'

Gem files will remain installed in /usr/local/lib/ruby/gems/1.9.1/gems/mysql-2.8.1 for inspection.

I really need to fix this problem and i dont have no idea how to

thanks for the help

if you’re on a mac, get homebrew, then type in your terminal “brew install mysql”

Hi,

I think you have to install mysql development stuff first.

In Centos I had the same problem, after i installed mysql-devel, I could install mysql without any erros.

Cheers,

where do i find those dev tools?

In my case (CentOS 5.5) i id a

$sudo yum -y install mysql-devel

I cant seem to find the equivalent of those packages for mac. If someone knows the steps for MacOSX i would sureley apreciate it.

It might be worth leaving a little more context in your postings. I don't know offhand which packages you're looking for as I'm just "checking in" on the list in a spare moment. I may not know the answer to your question, but if there was some judicious snipping of the original email I'd have a better shot at being able to answer. I'm sure I am not the only one.

Just a thought . . .

Best Wishes,
Peter

Phil

It might be worth leaving a little more context in your postings. I don’t know offhand which packages you’re looking for as I’m just “checking in” on the list in a spare moment. I may not know the answer to your question, but if there was some judicious snipping of the original email I’d have a better shot at being able to answer. I’m sure I am not the only one.

Just a thought . . .

Best Wishes,

Peter

I cant seem to find the equivalent of those packages for mac. If someone knows the steps for MacOSX i would sureley apreciate it.

If you have XCode installed, that’s all you need as far as dev packages. It includes compilers, development libraries, and so forth. You don’t really need to worry about it, as long as XCode is more or less completely installed, you’re good. It may be worthwhile making sure you have the latest version (free download from Apple, after all), but otherwise, you’re good.

For latest versions of Mac OS X, XCode, and the mysql gem, I’ve had no troubles; but you used to need to do something like:

gem install mysql – –with-mysql-config=/usr/local/mysql/bin/mysql_config

The big caveat, of course, is checking to see that this path in the example above is actually correct. If your mysql is in /opt/local or somewhere else, look there instead. This used to be a very common hurdle for installing the mysql gem on Mac OS X, so a few good Google searches should get you more suggestions than you even want… :slight_smile:

See thats the thing I have done everything by the book. and with the feedback i been getting but it stil says:

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/local/mysql/bin/mysql_config

checking for mysql_ssl_set()… *** 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

/usr/local/lib/ruby/1.9.1/mkmf.rb:368:in `try_do’:

The complier failed to generate an executable file. (RuntimeError)

You have to install development tools first.

from /usr/local/lib/ruby/1.9.1/mkmf.rb:435:in `try_link0'

from /usr/local/lib/ruby/1.9.1/mkmf.rb:440:in `try_link'

from /usr/local/lib/ruby/1.9.1/mkmf.rb:552:in `try_func'

from /usr/local/lib/ruby/1.9.1/mkmf.rb:797:in `block in have_func'

from /usr/local/lib/ruby/1.9.1/mkmf.rb:693:in `block in checking_for'

from /usr/local/lib/ruby/1.9.1/mkmf.rb:280:in `block (2 levels) in postpone'

from /usr/local/lib/ruby/1.9.1/mkmf.rb:254:in `open'

from /usr/local/lib/ruby/1.9.1/mkmf.rb:280:in `block in postpone'

from /usr/local/lib/ruby/1.9.1/mkmf.rb:254:in `open'

from /usr/local/lib/ruby/1.9.1/mkmf.rb:276:in `postpone'

from /usr/local/lib/ruby/1.9.1/mkmf.rb:692:in `checking_for'

from /usr/local/lib/ruby/1.9.1/mkmf.rb:796:in `have_func'

from extconf.rb:50:in `<main>'

Gem files will remain installed in /usr/local/lib/ruby/gems/1.9.1/gems/mysql-2.8.1 for inspection.

:frowning:

Just to ask, what does it say in mkmf.log?

Best Wishes,

Peter

this is what it says

"gcc -o conftest -I/usr/local/include/ruby-1.9.1/x86_64-darwin10.6.0 -I/usr/local/include/ruby-1.9.1/ruby/backward -I/usr/local/include/ruby-1.9.1 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/usr/local/mysql/include -Os -g -fno-common -fno-strict-aliasing -arch i386 -D_XOPEN_SOURCE=1 -fno-common -pipe conftest.c -L. -L/usr/local/lib -L. -L/usr/local/mysql/lib -lmysqlclient -lpthread -lruby.1.9.1-static -lpthread -ldl -lobjc "

In file included from /usr/local/include/ruby-1.9.1/ruby.h:32,

from conftest.c:1:

/usr/local/include/ruby-1.9.1/ruby/ruby.h:108: error: size of array ‘ruby_check_sizeof_long’ is negative

/usr/local/include/ruby-1.9.1/ruby/ruby.h:112: error: size of array ‘ruby_check_sizeof_voidp’ is negative

In file included from /usr/local/include/ruby-1.9.1/ruby/intern.h:29,

from /usr/local/include/ruby-1.9.1/ruby/ruby.h:1327,

from /usr/local/include/ruby-1.9.1/ruby.h:32,

from conftest.c:1:

/usr/local/include/ruby-1.9.1/ruby/st.h:69: error: size of array ‘st_check_for_sizeof_st_index_t’ is negative

checked program was:

/* begin */

1: #include “ruby.h”

2:

3: int main() {return 0;}

/* end */

Phil

this is what it says

"gcc -o conftest -I/usr/local/include/ruby-1.9.1/x86_64-darwin10.6.0 -I/usr/local/include/ruby-1.9.1/ruby/backward -I/usr/local/include/ruby-1.9.1 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/usr/local/mysql/include -Os -g -fno-common -fno-strict-aliasing -arch i386 -D_XOPEN_SOURCE=1 -fno-common -pipe conftest.c -L. -L/usr/local/lib -L. -L/usr/local/mysql/lib -lmysqlclient -lpthread -lruby.1.9.1-static -lpthread -ldl -lobjc "

In file included from /usr/local/include/ruby-1.9.1/ruby.h:32,

from conftest.c:1:

/usr/local/include/ruby-1.9.1/ruby/ruby.h:108: error: size of array ‘ruby_check_sizeof_long’ is negative

/usr/local/include/ruby-1.9.1/ruby/ruby.h:112: error: size of array ‘ruby_check_sizeof_voidp’ is negative

In file included from /usr/local/include/ruby-1.9.1/ruby/intern.h:29,

from /usr/local/include/ruby-1.9.1/ruby/ruby.h:1327,

from /usr/local/include/ruby-1.9.1/ruby.h:32,

from conftest.c:1:

/usr/local/include/ruby-1.9.1/ruby/st.h:69: error: size of array ‘st_check_for_sizeof_st_index_t’ is negative

checked program was:

/* begin */

1: #include “ruby.h”

2:

3: int main() {return 0;}

/* end */

I see ruby 1.9.1 there. I would absolutely recommend 1.9.2 or 1.8.7 instead… 1.9.1 had issues running rails, possibly other issues as well.

Not saying for certain that this is your problem with installing mysql, but you definitely want to change this; don’t use ruby 1.9.1.

So you might as well get the latest 1.9.2 or 1.8.7 (since you’ll need one or the other anyways) and then try gem install mysql again.

the folder says 1.9.1 but im using v 1.9.2

Hi,

As Phil said, it’s good to change to 1.9.2.

I am also quiet sure (90%) that the problem is because of mysql-devel.xxx. I spent more than half day because of this problem.

If there is a way to check if mysql-devel or mysql-dev is installed, do that check to confirm the cause of the problem.

You have to get your mysql-devel from somewhere and install it.

Cheers,

i think you might be right but im not sure how to check for it. if someone knows that be a great help

i FINALLY figured out the problem and what a minute detail for the trouble it made.

i was using mysql 32bit version

when i changed to mysql64bit version the problem went away

I didnt think that would be such a horrible problem for a minor compability detail

Thanks for the feedback guys

Please check :

The key change for us Ruby developers, is the fact that, in Snow Leopard, all the interpreted languages (including Ruby) are now running in 64-bit by default (obviously, only if you have a 64-bit machine). For pure Ruby applications and libraries this shouldn't pose any problems. But if you are migrating from a Leopard environment where you compiled C extensions for 32-bit only, these gems won't properly load in Snow Leopard. Same thing goes for libraries you might have compiled in 32-bit mode and that you might want to use on your migrated system. via rails blog.

Enjoy!

Bruno Barros (@bkether)