Skip to content

Instantly share code, notes, and snippets.

@thewoolleyman
Created October 22, 2010 16:54
Show Gist options
  • Save thewoolleyman/640944 to your computer and use it in GitHub Desktop.
Save thewoolleyman/640944 to your computer and use it in GitHub Desktop.
mysql_snow_leopard_homebrew_gem_compile_problems.markdown
To follow up, this just "started working". I had introduced an unrelated error with debugging code in mkmf.rb. Once I removed that, everything compiled.
I suspect this (plus a reboot) was the magic fix:
Specified 64-bit arch in boot plist:
$ sudo vi /Library/Preferences/SystemConfiguration/com.apple.Boot.plist
# add: "<string>arch=x86_64</string>"
Mysql Snow Leopard Homebrew Gem Compilation Problems
====================================================
System Info
-----------
Hardware Overview:
Model Name: iMac
Model Identifier: iMac7,1
Processor Name: Intel Core 2 Duo
Processor Speed: 2.4 GHz
Number Of Processors: 1
Total Number Of Cores: 2
L2 Cache: 4 MB
Memory: 4 GB
Bus Speed: 800 MHz
Boot ROM Version: IM71.007A.B03
SMC Version (system): 1.21f4
Serial Number (system): W88140X4X89
Hardware UUID: 00000000-0000-1000-8000-001F5BE7730A
System Software Overview:
System Version: Mac OS X 10.6.4 (10F569)
Kernel Version: Darwin 10.4.0
64-bit Kernel and Extensions: No
Check Firmware:
$ ioreg -l -p IODeviceTree | grep firmware-abi # check firmware
| | "firmware-abi" = <"EFI64">
Specified 64-bit arch in boot plist:
$ sudo vi /Library/Preferences/SystemConfiguration/com.apple.Boot.plist
# add: "<string>arch=x86_64</string>"
Hardware name:
uname -m
i386
Homebrew and Mysql Info
-----------------------
$ brew info mysql
mysql 5.1.51
http://dev.mysql.com/doc/refman/5.1/en/
Depends on: readline
/usr/local/Cellar/mysql/5.1.51 (221 files, 83M)
Gem Installation Errors
-----------------------
mysql2 gem install command:
export ARCH_FLAG=x86_64 && gem install mysql2 -- --with-mysql-dir=/usr/local/Cellar/mysql/5.1.51 --with-mysql-config /usr/local/bin/mysql_config --srcdir=/usr/local/Cellar/mysql/5.1.51/include/mysql/
Gets error:
mysql.h is missing. please check your installation of mysql and try again.
Here is the entire mkmf.log output:
$ cd /Users/myuser/.rvm/gems/ree-1.8.7-2010.02/gems/mysql2-0.2.6/ext/mysql2
$ cat mkmf.log
"gcc -o conftest -I. -I/Users/myuser/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/i686-darwin10.4.0 -I/usr/local/Cellar/mysql/5.1.51/include/mysql/ -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -g -O2 -pipe -fno-common conftest.c -L. -L/Users/myuser/.rvm/rubies/ree-1.8.7-2010.02/lib -L. x86_64 -lruby-static -ldl -lobjc "
i686-apple-darwin10-gcc-4.2.1: x86_64: No such file or directory
conftest.c: In function ‘t’:
conftest.c:3: error: ‘rb_thread_blocking_region’ undeclared (first use in this function)
conftest.c:3: error: (Each undeclared identifier is reported only once
conftest.c:3: error: for each function it appears in.)
checked program was:
/* begin */
1: /*top*/
2: int main() { return 0; }
3: int t() { void ((*volatile p)()); p = (void ((*)()))rb_thread_blocking_region; return 0; }
/* end */
"gcc -o conftest -I. -I/Users/myuser/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/i686-darwin10.4.0 -I/usr/local/Cellar/mysql/5.1.51/include/mysql/ -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -g -O2 -pipe -fno-common conftest.c -L. -L/Users/myuser/.rvm/rubies/ree-1.8.7-2010.02/lib -L. x86_64 -lruby-static -ldl -lobjc "
i686-apple-darwin10-gcc-4.2.1: x86_64: No such file or directory
checked program was:
/* begin */
1: /*top*/
2: int main() { return 0; }
3: int t() { rb_thread_blocking_region(); return 0; }
/* end */
--------------------
"gcc -E -I. -I/Users/myuser/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/i686-darwin10.4.0 -I/usr/local/Cellar/mysql/5.1.51/include/mysql/ -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/usr/local/Cellar/mysql/5.1.51/include/mysql -arch i386 -arch x86_64 -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT -DDONT_DECLARE_CXA_PURE_VIRTUAL -g -O2 -pipe -fno-common conftest.c -o conftest.i"
gcc-4.2: -E, -S, -save-temps and -M options are not allowed with multiple -arch flags
checked program was:
/* begin */
1: #include <mysql.h>
/* end */
--------------------
"gcc -E -I. -I/Users/myuser/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/i686-darwin10.4.0 -I/usr/local/Cellar/mysql/5.1.51/include/mysql/ -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/usr/local/Cellar/mysql/5.1.51/include/mysql -arch i386 -arch x86_64 -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT -DDONT_DECLARE_CXA_PURE_VIRTUAL -g -O2 -pipe -fno-common conftest.c -o conftest.i"
gcc-4.2: -E, -S, -save-temps and -M options are not allowed with multiple -arch flags
checked program was:
/* begin */
1: #include <mysql/mysql.h>
/* end */
--------------------
Which, from my debugging, comes down to this command failing with a nonzero return code when searching for mysql.h, even though it DOES exist in /usr/local/Cellar/mysql/5.1.51/include/mysql/:
gcc -E -I. -I/Users/myuser/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/i686-darwin10.4.0 -I/usr/local/Cellar/mysql/5.1.51/include/mysql/ -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/usr/local/Cellar/mysql/5.1.51/include/mysql -arch i386 -arch x86_64 -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT -DDONT_DECLARE_CXA_PURE_VIRTUAL -g -O2 -pipe -fno-common conftest.c -o conftest.i
And there's also this error printed in mkmf, which seems important, but I don't know what it means:
i686-apple-darwin10-gcc-4.2.1: x86_64: No such file or directory
Similar problems occur with mysql gem as well as mysql2 gem.
Related Links:
--------------
* Problems compiling native gems under Snow Leopard + RVM: [http://gist.github.com/456916](http://gist.github.com/456916)
* First pass at above problem, with some relevant links: [http://gist.github.com/440334#file_gistfile1.txt](http://gist.github.com/440334#file_gistfile1.txt)
* Another similar problem: [http://gist.github.com/466341](http://gist.github.com/466341)
@yangkookkim
Copy link

I had the same problem of "mysql.h is missing." even if the file does exist under /usr/local/Cellar/mysql/${version}/include.
The fix for me was first uninstalling mysql from homebrew and then reinstalling it. After doing that, make properly found mysql.h under right location.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment