bundle install problem: mysql.h is missing

有些话、适合烂在心里 提交于 2019-11-28 03:41:28
guido

I tried all the solutions posted here, but was not lucky. I reinstalled mysql with homebrew a couple of times and still no luck. Then I came across a blog post with a solution.

I edited the mysql_config file in /usr/local/Cellar/mysql/5.6.12/bin and removed the W-compiler options -Wno-null-conversion and -Wno-unused-private-field for cflags and cxxflags.

This solved the problem with gem install mysql2 and bundle install

Reference: http://www.randomactsofsentience.com/2013/05/gem-install-mysql2-missing-mysqlh-on-os.html

db365

I did a bundle install on a redmine repo and got the same error message :

mysql.h is missing. please check your installation of mysql and try again.

Running Fedora 16 64 bits, all I did was install mysql-devel (development package) from the distro rpm and the problem was solved!

So I think you could just

yum install mysql-devel

or apt-get the missing devel package.

okliv

for people who didn't use brew to install mysql and use mysql 5.6 and higher:

according to this answer

you need to edit mysql_config which was placed in my case here: /usr/local/mysql-5.6.12-osx10.7-x86_64/bin

and change cflags and cxxflags to:

cflags="-I$pkgincludedir  -Wall -Os -g -fno-strict-aliasing -DDBUG_OFF " #note: end space!
cxxflags="-I$pkgincludedir  -Wall -Os -g -fno-strict-aliasing -DDBUG_OFF " #note: end space!

after this manipulations

$ gem install mysql2 -v '0.3.13'

goes flawlessly

Ok guys for me the solution was:

$ sudo brew install mysql

$ sudo env ARCHFLAGS="-arch i386" gem install mysql -- \
  --with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib \
  --with-mysql-include=/usr/local/mysql/include

source: http://wonko.com/post/how-to-install-the-mysqlruby-gem-on-mac-os-x-leopard

OR :

$sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- \
  --with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib \
  --with-mysql-include=/usr/local/mysql/include

If your mysql version is 64Bits

After that i had a lot of problems because if i want to create the database:

$: bundle exec rake db:reset

i was receiving this error:

dyld: lazy symbol binding failed: Symbol not found: _mysql_init
  Referenced from: /Users/workdreamer/Sites/cavortify/implementation/cavortify/mysql/ruby/1.8/gems/mysql-2.8.1/lib/mysql_api.bundle
  Expected in: flat namespace

dyld: Symbol not found: _mysql_init
  Referenced from: /Users/workdreamer/Sites/cavortify/implementation/cavortify/mysql/ruby/1.8/gems/mysql-2.8.1/lib/mysql_api.bundle
  Expected in: flat namespace

The solution is: On your gemfile add: gem "ruby-mysql"

Ok, one day and a half to find the solution.

Have a nice day!

This method is for Rails 3.1.0 (and hopefully up) on 64 bit machine. I used on Ruby-1.9.2-p180.

This blog answered it: http://www.tatvartha.com/2010/10/installing-mysql-gem-with-bundler-on-snow-leopard/

Basically, the method above: $ sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

may work, but without bundler.

To do it with bundler, first must run this on terminal:

bundle config build.mysql2 --with-mysql-config=/usr/local/mysql/bin/mysql_config

Note "mysql2" not "mysql" as shown in that blog.

That adds a config to ~/.bundle/config file

Then add this to ~/.bash_profile:

export ARCHFLAGS="-arch x86_64"

That is the same with telling bundler to run the command on top of this post.

The only way I could get this to work was to install the x64 version of mysql. I just used the .dmg located here http://dev.mysql.com/downloads/mysql/ and it worked like a charm. Wish I could get the 4 hours back it took to figure this out.

user2382793

This worked for me on my Mac OSX Lion:

sudo env ARCHFLAGS="-I/usr/local/include/mysql/mysql  -pipe -fPIC    -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT  -DDONT_DECLARE_CXA_PURE_VIRTUAL" gem install mysql -- --with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/lib/mysql/mysql --with-mysql-include=/usr/local/include/mysql/mysql --with-mysql-config=/usr/local/bin/mysql_config

This blog answered it.

For mariadb:

sudo apt-get install libmariadbclient18 libmariadbclient-dev

Then

gem install mysql2

could be successfully installed.

Verify that gcc is installed. If it isn't, you will get that same error message.

You can check the results/log file it mentions for more clues as to the cause.

Posting this wherever I can--hopefully it will help someone and save them a lot of time.

I dug through 2 days worth of the internet and Stack Overflow, and it wasn't until I found this link and then starting working through this ticket for mysql2 that I actually resolved the issue.

With my setup (as explained in the ticket), the compiler switches of -Wno-null-conversion -Wno-unused-private-field would break and give me an error that wasn't exactly correct, which was:

mysql.h is missing. please check your installation of mysql and try again

My problem was the result of first installing MySql via the downloadable binary. It was originally installed at version 5.5.28. I then attempted to install via homebrew. Brew installed version 5.6.x. HOWEVER in the process of installing via homebrew, the symlink for /usr/local/mysql was still pointed to 5.5.28.

Update your symlink to whichever version was installed via homebrew.

ex: /usr/local/mysql -> /usr/local/Cellar/mysql/5.6.13/

This could be just part of the solution.

For those on Fedora 21, and you already installed mysql-devel:

yum install redhat-rpm-config

solved the problem for me. see: redhat docs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!