Bug #23201 Problems compiling client (mysql ruby gem)
Submitted: 12 Oct 2006 8:43 Modified: 21 Nov 2006 14:33
Reporter: Jean-Marc Borer Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.0.26 OS:MacOS (Mac OS X 10.4.8)
Assigned to: CPU Architecture:Any
Tags: ruby gem mac

[12 Oct 2006 8:43] Jean-Marc Borer
Description:
Impossible to install and compile the mysql ruby gem with mysql 5.0.26 for mac osx

How to repeat:
- install ruby
- install ruby gems

you can follow the guidelines at: http://hivelogic.com/articles/2005/12/01/ruby_rails_lighttpd_mysql_tiger but instead of installing mysql 4.1.x, install mysql 5.0.26 

then at the stage sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql
 you will get:

aluminium:~ jeanmarc$ sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql
Password:
Need to update 12 gems from http://gems.rubyforge.org
............
complete
Select which gem to install for your platform (powerpc-darwin8.5.0)
 1. mysql 2.7.1 (mswin32)
 2. mysql 2.7 (ruby)
 3. mysql 2.6 (ruby)
 4. mysql 2.5.1 (ruby)
 5. Cancel installation
> 2
Building native extensions.  This could take a while...
mysql.c: In function 'Init_mysql':
mysql.c:2015: error: 'ulong' undeclared (first use in this function)
mysql.c:2015: error: (Each undeclared identifier is reported only once
mysql.c:2015: error: for each function it appears in.)
mysql.c:2015: error: parse error before numeric constant
mysql.c:2018: error: parse error before numeric constant
make: *** [mysql.o] Error 1
mysql.c: In function 'Init_mysql':
mysql.c:2015: error: 'ulong' undeclared (first use in this function)
mysql.c:2015: error: (Each undeclared identifier is reported only once
mysql.c:2015: error: for each function it appears in.)
mysql.c:2015: error: parse error before numeric constant
mysql.c:2018: error: parse error before numeric constant
make: *** [mysql.o] Error 1
ruby extconf.rb install mysql -- --with-mysql-dir=/usr/local/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... yes
checking for mysql_query() in -lmysqlclient... yes
checking for mysql_ssl_set()... yes
checking for mysql.h... yes
creating Makefile

make
gcc -fno-common -g -O2 -pipe -fno-common  -I. -I/usr/local/lib/ruby/1.8/powerpc-darwin8.5.0 -I/usr/local/lib/ruby/1.8/powerpc-darwin8.5.0 -I. -DHAVE_MYSQL_SSL_SET -DHAVE_MYSQL_H -I/usr/local/mysql/include  -c mysql.c

make install
mkdir -p /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7/lib
gcc -fno-common -g -O2 -pipe -fno-common  -I. -I/usr/local/lib/ruby/1.8/powerpc-darwin8.5.0 -I/usr/local/lib/ruby/1.8/powerpc-darwin8.5.0 -I. -DHAVE_MYSQL_SSL_SET -DHAVE_MYSQL_H -I/usr/local/mysql/include  -c mysql.c

make clean
Successfully installed mysql-2.7
aluminium:~ jeanmarc$ 

the gem is installed, but the binding library is not created.

Suggested fix:
The issue is related to the macro CLIENT_MULTI_STATEMENTS defined in file mysql_com.h:

#define CLIENT_MULTI_STATEMENTS (((ulong) 1) << 16)   /* Enable/disable multi-stmt support */

The type ulong doesn't exist in mac os x 10.4.8. To fix the compilation you must simply define the type ulong at the top of the file mysql_com.h file as

#define ulong unsigned long
[21 Nov 2006 14:33] Valeriy Kravchuk
Thank you for your bug report. This issue has been committed to our source repository of that product and will be incorporated into the next release.

In 5.0.32-BK we have:

#define CLIENT_MULTI_STATEMENTS (1UL << 16) /* Enable/disable multi-stmt support
 */

If necessary, you can access the source repository and build the latest available version, including the bug fix. More information about accessing the source trees is available at

    http://dev.mysql.com/doc/en/installing-source.html

I hope, now it will work on Mac OS X.