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?
Related
I'm trying to install image-2.6.1 package to GNU Octave, version 4.0.0. I downloaded image-2.6.1.tar.gz and tried to install it with
pkg install /home/vladimirmatveev/Downloads/image-2.6.1.tar.gz
but get an error.
configure: error: in `/tmp/oct-BAtlFb/image-2.6.1/src':
configure: error: C++ compiler cannot create executables
See `config.log' for more details
checking for a sed that does not truncate output... /bin/sed
checking for octave... /usr/bin/octave
checking for mkoctfile... /usr/bin/mkoctfile
checking whether the C++ compiler works... no
pkg: error running the configure script for image.
error: called from 'configure_make' in file /usr/share/octave/4.0.0/m/pkg/private/configure_make.m near line 79, column 9
I am sure I have C/C++ compilers, they are gcc and g++ (when I am trying to install them with apt-get it says I already have a newest version and I am sure it is true).
I tried to set c/c++ compilers to system variables with
export CC=/usr/bin/gcc-4.8
export CXX=/usr/bin/g++-4.8
or
export CC=/usr/bin/gcc-5
export CXX=/usr/bin/g++-5
(I have both versions) but it didn't helped. It usually works for me when cmake can not find a compiler.
I found im-config.log file, but it contains only
Script for ibus started at run_im.
Script for auto started at run_im.
Script for default started at run_im.
I am not sure this is that config file which was mentioned in error message, but it is the only file which has suitable modification date.
I am working at ubuntu 16.04.
I unpackaged .tar.gz, cd to it and to src/, then run ./configure and there was no troubles found while checking compiler, here is the console log.
checking for a sed that does not truncate output... /bin/sed
checking for octave... /usr/bin/octave
checking for mkoctfile... /usr/bin/mkoctfile
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether /usr/bin/g++-5 accepts -g... yes
checking for /usr/bin/g++-5 option to enable C++11 features... -std=gnu++11
checking whether xmin is in the octave::math namespace... no
checking whether templated lambda functions accept '&const int'... yes
configure: creating ./config.status
config.status: creating im2double.m
config.status: creating Makefile
config.status: creating config.h
Here is full config log http://pastebin.com/u6MNSqCB
So I was following along with this tutorial:
https://www.youtube.com/watch?v=MX6wYbsUO-Y
It uses git.bash to install the mysql2 gem, and I'm stuck on the final step. The process he uses won't work for me, so instead, i just type:
gem install mysql2 -s http://rubygems.org
After this, it begins to work, but then it says the mysql client is missing:
gem install mysql2-0.3.7.gem --platform=ruby -- --with-mysql-dir=X: --with-mysql-lib=X:\lib
ERROR: Failed to build gem native extension.
c:/RailsInstaller/Ruby2.1.0/bin/ruby.exe 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
checking for mysql_query() in -lmysqlclient... no
-----
mysql client is missing. Check your installation of MySQL or Connector/C, and try again.
-----
*** 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.
I am very new to using mysql, and I don't even know where to begin, if anything, could anyone simply direct me to a resource where I could figure it out myself?
First of all please provide the version numbers when you are asking specific platform related questions
This is a 2 year old question but the problem still exists when starting ruby on windows
here are some steps needed to solve it ( as of aug 2017)
Please install Devkit and MSYS(now comes with ruby installer)
when installing mysql2 gem check if the version supplied from the rubygem repo is actually for your architecture and ruby version e.g. mysql2 0.4.9 does not provide compiled version for windows for ruby 2.4
if it is not provided then you need to compile it
3.a. First download the Mysql c connector from here the zip version is better
https://dev.mysql.com/downloads/connector/c/
important please keep in mind of your os architecture for example you must download 64 bit if you want to run it on 64 bit machine
3.b. Second extract it somewhere and the run this command
gem install mysql2 --platform=ruby -- '--with-mysql-lib="[your_full_path_to_extracted_mysql_connector]\lib" --with-mysql-include="[your_full_path_to_extracted_mysql_connector]\include"'
please keep in mind of the ' at the end it is important
It should say 1 gem installed
Check your connection using this command
rails db:schema:dump inside your project root directory. you will see a
new file in the db folder named schema.rb it means that it is working.
You will see specific problems displayed in the console, if any search it in the google you will find answers.
good luck :)
You need to download and install MySQL first.
If it's still not able to be found after you've installed it, supply the path on gem install.
I gave ./configure in tclreadline for tclreadline2.1.0 and got this error
loading cache ./config.cache
checking for a BSD compatible install... (cached) /usr/bin/install -c
checking whether build environment is sane... yes
checking whether make sets ${MAKE}... (cached) yes
checking for working aclocal... found
checking for working autoconf... found
checking for working automake... found
checking for working autoheader... found
checking for working makeinfo... found
checking whether make sets ${MAKE}... (cached) yes
checking host system type... Invalid configuration `x86_64-unknown-linux-gnu': machine `x86_64-unknown' not recognized
checking for gcc... (cached) gcc
checking whether the C compiler (gcc ) works... yes
checking whether the C compiler (gcc ) is a cross-compiler... no
checking whether we are using GNU C... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for Cygwin environment... (cached) no
checking for mingw32 environment... (cached) no
checking for executable suffix... (cached) no
checking build system type... Invalid configuration `x86_64-unknown-linux-gnu': machine `x86_64-unknown' not recognized
checking for ranlib... (cached) ranlib
checking for ld used by GCC... (cached) /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... (cached) yes
checking for BSD-compatible nm... (cached) /usr/bin/nm -B
checking whether ln -s works... (cached) yes
loading cache ./config.cache within ltconfig
checking host system type... Invalid configuration `x86_64-unknown-linux-gnu': machine `x86_64-unknown' not recognized
configure: error: libtool configure failed
Please suggest what to done to compile properly
Thanks for the help in advance
Found the answer here. To get old configure scripts working, you can update the config.sub file:
curl 'http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD' > config.sub
This will replace the config.sub script with the latest version.
The package looks like it hasn't been maintained in a long time. Consequently, the autotools used to build the configure script and auxiliary files probably aren't even aware of x86-64.
Assuming you have the autotools installed - autoconf, automake, libtool, etc. - you could try running autoreconf -ivf, and then attempting ./configure again. You'll probably get a lot of warnings about out-of-date macros, etc. But it might work.
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