# Mysql gem install error on Mac OS X - 'ulong' undeclared error

**URL:** <https://www.ruby-forum.com/t/mysql-gem-install-error-on-mac-os-x-ulong-undeclared-error/134565>\
**Category:** Rails\
**Created:** [April 12, 2008, 4:25am UTC](https://www.ruby-forum.com/t/mysql-gem-install-error-on-mac-os-x-ulong-undeclared-error/134565 "2008-04-12T04:25:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [April 12, 2008, 4:25am UTC](https://www.ruby-forum.com/t/mysql-gem-install-error-on-mac-os-x-ulong-undeclared-error/134565/1 "2008-04-12T04:25:39Z")

</div>

Hi,

I can’t seem to install the mysql gem for Ruby (see errors below). I get  
an  
‘ulong’ undeclared error. Can anyone assist?

============ERROR=========================

Macintosh:mysql-2.7 greg$ sudo gem install mysql –  
–with-mysql-config=/usr/local/mysql/bin/mysql\_config

Password:

Building native extensions. This could take a while…

ERROR: Error installing mysql:

ERROR: Failed to build gem native extension.

/opt/local/bin/ruby extconf.rb install mysql –  
–with-mysql-config=/usr/local/mysql/bin/mysql\_config

checking for mysql\_ssl\_set()… yes

checking for mysql.h… yes

creating Makefile

make

gcc -I. -I. -I/opt/local/lib/ruby/1.8/i686-darwin8.10.1 -I.  
-DHAVE\_MYSQL\_SSL\_SET -DHAVE\_MYSQL\_H -I/opt/local/include  
-I/usr/local/mysql/include -Os -arch i386 -fno-common -fno-common -O2  
-fno-common -pipe -fno-common -c mysql.c

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: syntax error before numeric constant

mysql.c:2018: error: syntax error before numeric constant

make: \*\*\* [mysql.o] Error 1

Gem files will remain installed in  
/opt/local/lib/ruby/gems/1.8/gems/mysql-2.7 for inspection.

Results logged to  
/opt/local/lib/ruby/gems/1.8/gems/mysql-2.7/gem\_make.out

===========VERSION INFO==========================

Macintosh:mysql-2.7 greg$ ruby --version

ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-darwin8.10.1]

Macintosh:mysql-2.7 greg$ rails --version

Rails 2.0.2

Macintosh:mysql-2.7 greg$ gem --version

1.1.0

=========MacBook Details============================

Model Name: MacBook

Model Identifier: MacBook2,1

Processor Name: Intel Core 2 Duo

Processor Speed: 2 GHz

System Version: Mac OS X 10.5.2 (9C7010)

Kernel Version: Darwin 9.2.2

Regards

Greg

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [April 12, 2008, 5:32am UTC](https://www.ruby-forum.com/t/mysql-gem-install-error-on-mac-os-x-ulong-undeclared-error/134565/2 "2008-04-12T05:32:16Z")

</div>

> I can’t seem to install the mysql gem for Ruby (see errors below). I get an  
> ‘ulong’ undeclared error. Can anyone assist?

Hopefully this will help…

[http://jlaine.net/2006/10/3/installing-ruby-mysql-driver-on-os-x](http://jlaine.net/2006/10/3/installing-ruby-mysql-driver-on-os-x)

(read through the comments as well)

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [September 23, 2010, 12:18am UTC](https://www.ruby-forum.com/t/mysql-gem-install-error-on-mac-os-x-ulong-undeclared-error/134565/3 "2010-09-23T00:18:22Z")

</div>

Philip H. wrote:

> > I can’t seem to install the mysql gem for Ruby (see errors below). I get an  
> > ‘ulong’ undeclared error. Can anyone assist?
> 
> Hopefully this will help…
> 
> [http://jlaine.net/2006/10/3/installing-ruby-mysql-driver-on-os-x](http://jlaine.net/2006/10/3/installing-ruby-mysql-driver-on-os-x)
> 
> (read through the comments as well)

I have tried the solutions above and no success. Finally I decided to  
add #define ulong unsigned long to  
/usr/include/stdlib.h and tried installing again and voila, it worked !

Have also suggested this solution to many people and so far have not  
found any issues with it.
