I'm trying to install the mysql gem under Windows 7 x64. Ruby -v is ruby 1.8.6 (2009-03-31 patchlevel 368) [i386-mingw32] and gem is 1.3.4. So the problem is, when I try to "gem install mysql", I get the following error:
D:\ruby\lib\ruby\gems\1.8\gems\mysql-2.7>gem install mysql
Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
D:/ruby/bin/ruby.exe extconf.rb
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... no
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... no
checking for mysql_query() in -lmysqlclient... no
*** extconf.rb failed ***
I've tried to add the mysql bin to the PATH as described here, it didn't help just as adding different variations of --with-mysql (-dir, -lib etc.) to the instruction. How can I finally fix it? TIA
I don't think that the mysql gem has been released for the mingw32 build of Ruby yet, although there definitely seems to be something coming on that front.
More significantly, the one-click installer is not production on mingw32 yet at all, although it's getting there, and the biggest outstanding item is getting all compiled gems to compatibility.
You can either try putting together a mingw32-gcc build environment and trying to build the library yourself or drop back to the 1.8.6 mswin32 installer and runtime for now and monitor the one-click installer's progress.
Unless someone else knows different, of course?
Related
This question already has answers here:
Ruby Gem install Json fails on Mavericks and Xcode 5.1 - unknown argument: '-multiply_definedsuppress'
(11 answers)
Closed 8 years ago.
I was installing mysql2 in terminal on my mac but there was an error message. Does anyone know how to solve this problem? Thanks a lot!
my osx version is 10.9 and have installed Xcode and command line tool.
joe#~ $sudo gem install mysql2
Password:
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
-----
Using mysql_config at /usr/local/bin/mysql_config
-----
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
-----
Setting rpath to /usr/local/Cellar/mysql/5.6.17/lib
-----
creating Makefile
make "DESTDIR="
compiling client.c
compiling infile.c
compiling mysql2_ext.c
compiling result.c
linking shared-object mysql2/mysql2.bundle
clang: error: unknown argument: '-multiply_definedsuppress' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
make: *** [mysql2.bundle] Error 1
Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/mysql2-0.3.15 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/gems/mysql2-0.3.15/ext/mysql2/gem_make.out
The error message says, `clang: error: unknown argument: '-multiply_definedsuppress' [-Wunused-command-line-argument-hard-error-in-future]. It seems that the option '-multiply_definedsuppress' is not currently accepted as an option by your compiler when installing it. You need to make your compiler accept it for the time being.
According to Xcode 5.1 Release Notes:
The Apple LLVM compiler in Xcode 5.1 treats unrecognized command-line options as errors. This issue has been seen when building both Python native extensions and Ruby Gems, where some invalid compiler options are currently specified.
Projects using invalid compiler options will need to be changed to remove those options. To help ease that transition, the compiler will temporarily accept an option to downgrade the error to a warning: -Wno-error=unused-command-line-argument-hard-error-in-future
Therefore, you may want to try running:
ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install mysql2
On a CentOS 5.7 box, I'm having trouble installing the newest version of the mysql2 gem; it's not finding errmsg.h:
/usr/bin/ruby extconf.rb
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... no
checking for mysql_query() in -lmysqlclient... yes
checking for mysql.h... no
checking for mysql/mysql.h... yes
checking for errmsg.h... no
-----
errmsg.h is missing. please check your installation of mysql and try again.
-----
*** extconf.rb failed ***
The mysql header files exist at /usr/include/mysql. An older version of the gem exists on the server, so it must have been built successfully at one point.
Note that it fails on a check for mysql.h, but succeeds on mysql/mysql.h. However, it doesn't repeat this for errmsg.h. By this I'm guessing that it's not looking at /usr/include, but I'm not sure.
I've dug into the extconf.rb source code and discovered that it's using the have_header method to locate the header files. I debugged the execution to find out that it's looking for a relative path of "mysql/errmsg.h". But I haven't found any documentation that explains how it expands that into an absolute path.
Where & how does have_header locate its header files?
I believe I've found an answer.
It appears that have_header looks at the system include path. If the relevant environment variables are not set, the default include paths are /usr/local/include and /usr/include.
If you want to set them manually, you would do something like:
export C_INCLUDE_PATH=/usr/include/mysql/
That's true even if you're compiling a C++ program, if the header file is a C file. If, on the other hand, your header file is C++, not C, you would do:
export CPLUS_INCLUDE_PATH=/usr/include/mysql
Of course, you found the work-around, which is to include dir_config('mysql') in your extconf.rb. That enables you to use the --with-mysql-include option and supply the path manually.
Here's my source: http://www.network-theory.co.uk/docs/gccintro/gccintro_23.html
And here's a more general version of the same question (with answers): How to add a default include path for gcc in linux?
I have the JRuby MySQL gem installed on my machine. However, for some reason I had to change to Ruby instead of JRuby and everything seems to be working fine except that the MySQL gem for Ruby isn't installed and now when I try to install it I get following error:
Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.8 extconf.rb --with-mysql-dir=/usr/include/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... no
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
checking for main() in -lmygcc... no
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
I googled and found that I might need to install the libmysqlclient12-dev package.
But when I tried doing that, I got following error:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package libmysqlclient12-dev is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package libmysqlclient12-dev has no installation candidate
Now I seem to be hitting the wall and not move ahead with this. Any pointers or help will be appreciated.
Cheers
I had the same issue. I did
apt-get install libmysqlclient-dev
on Ubuntu, and it worked.
Which gem command are you using? The ruby one or the jruby one?
Try which gem if you're on *unix.
Have a look at your path to make sure the C-ruby binaries are in front of the JRuby binaries (or remove JRuby from your path if you're not going to use it anymore).
I'm guessing from the package manager that you're running Linux.
libmysqlclient12-dev is an Ubuntu package. If you're running some other distro it's very probably just named something else. I believe that the Fedora package you'd need is mysql-devel. If you do some searching around with the name of your distro and libmysqlclient12-dev you can probably find exactly what it is.
Your distribution may also have pre-built versions of some of the gems. Fedora (which is what I use) doesn't have a mysql gem pre-built, but another distrubution might. In Fedora they're named rubygem-GEMNAME depending on the gem. For example, the sqlite pre-built gem is rubygem-sqlite3-ruby.
My end goal is local development of a Radiant CMS installation. So, need rails and a db to play nice. Previous frustrations with mysql led me to try mamp. I have installed MAMP. It is working. I am open to other avenues though.
Tried to install the mysql gem but got no love.
john-breedloves-mac-mini-2:~ john_breedlove$ sudo gem install mysqlPassword:
Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
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... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
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:
<Omitted>
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/mysql-2.8.1 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out
I have found a lot of advice about installing gems after upgrading to snow leopard but all the good answers seem to point people to getting the 64bit version of mysql installed. I have a 32bit processor.
I have xcode installed.
How do I get this gem installed?
Have you installed mysql on the machine ?
That's the first thing you must do.
Then the problem with Mac OS is that it doesn't install things at the same standard emplacement than on linux. So you must specify the mysql directory.
With macports mysql, I do the following :
sudo gem install mysql --with-mysql-include=/opt/local/include/mysql5 --with-mysql-lib=/opt/local/lib/mysql5 --with-mysql-config=/opt/local/lib/mysql5/bin/mysql_config
Short story is you are going to need to compile mysql by hand to get the libraries you need.
By the time you do that, you might not need mamp :P I just kick off mysql manually, and use the dev environment.
http://hivelogic.com/articles/compiling-mysql-on-snow-leopard/
Edit: Just noticed you found Hivelogic. That is the way to go. Once it is compiled, you can't point the mysql gem in the correct direction per the instructions. Also, I believe getting the docs working for the gem is a whole other headache, i would just let it slide.
If you installed mysql through homebrew you might use this:
sudo gem install mysql -- --with-mysql-include=/usr/local/include/mysql --with-mysql-lib=/usr/local/lib/mysql
The '--' is helpful when adding additional configuration parameters.
With bundler you should do something like so:
# bundle config build.mysql --with-mysql-config=/usr/local/bin/mysql_config
# bundle install
So, installing Ruby Enterprise Edition went fairly smoothly (except for a very odd quirk of the system I'm on, where I had to apt-get install build-essentials because there was no GCC...), but it failed to install any of the database gems properly. I mainly want to use MySQL. Here's the output of Ruby EE's ./installer during the mysql gem installation:
Installing mysql...
/opt/ruby-enterprise-1.8.6-20090610/bin/ruby /opt/ruby-enterprise-1.8.6-20090610/bin/gem install -r --no-rdoc --no-ri --no-update-sources --backtrace mysql
Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
/opt/ruby-enterprise-1.8.6-20090610/bin/ruby extconf.rb
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
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... no
*** extconf.rb failed ***
Apparently my server's MySQL installation didn't come with source, so I can't just recompile and hope it works... I tried to download the version and compile that, but I'm not sure what to do from here. Any ideas? MySQL is already running on this server with quite a few databases, so I'd also rather not mess with what's already here...
After a fair bit of struggle, I started browsing through aptitude hoping to find a package that might solve the problem. I found libmysqlclient-dev, installed it, and rebuilt the gem... and it worked. I feel pretty stupid, heh, but this is only my first time trying to deploy a Rails app to a real webserver.
Is your system 64bit? The problem is that the gem installer can't find mysqlclient.
1) Use locate to make sure that mysqlclient and mysql_config are on your system. You may need to first update the locate db. -- locate mysqlclient should show you a number of library files ending in .so, .a, etc.
2) Try
/opt/ruby-enterprise/bin/ruby /opt/ruby-enterprise/bin/gem install mysql -- --with-mysql-config='/usr/bin/mysql_config' --no-rdoc --no-ri
(update the above to use right dir for mysql_config and ruby-enterprise)
Larry