mysql.h is missing … (Ruby on Rails, OSX)

前端 未结 5 473
情深已故
情深已故 2020-12-24 15:07

I tried several ideas ... none of them worked ... I\'m just trying to install mysql2 as a gem. My mysql is working, but every time my system says, that mysql.h is missing .

5条回答
  •  执念已碎
    2020-12-24 15:32

    If you're using the standard XAMPP this could be the problem, you could probably need to install xampp-devel which is the development package for xampp, this distribution contains mysql headers *.h files as well as other related sources, you can find older versions in here.

    you can than copy the include directory in your /Applications/XAMPP/xamppfiles then install gem using this command:

    sudo gem install mysql2 -v 0.3.21 -- --with-mysql-config=/Applications/XAMPP/xamppfiles/bin/mysql_config --with-mysql-include=/Applications/XAMPP/xamppfiles/lib/include/ --no-ri --no-rdoc
    

    this version worked for me, and don't need to include --with-mysql-dir if you specify mysql_config path, and then you should get a similar output:

    This could take a while...
    Successfully installed mysql2-0.3.21
    Parsing documentation for mysql2-0.3.21
    Installing ri documentation for mysql2-0.3.21
    Done installing documentation for mysql2 after 0 seconds
    1 gem installed
    

    you may also need to provide rails with the correct version of libmysqlclient, here is an example using Symlink:

    sudo ln -s /Applications/XAMPP/xamppfiles/lib/libmysqlclient.18.dylib /usr/local/lib/libmysqlclient.18.dylib
    

    Don't forget in update bundle packages.

提交回复
热议问题