# MySQL gem on 64-bit Solaris won't compile

**URL:** <https://www.ruby-forum.com/t/mysql-gem-on-64-bit-solaris-wont-compile/125952>\
**Category:** Ruby\
**Created:** [January 14, 2008, 4:02am UTC](https://www.ruby-forum.com/t/mysql-gem-on-64-bit-solaris-wont-compile/125952 "2008-01-14T04:02:56Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![armstheykill](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@armstheykill](https://www.ruby-forum.com/u/armstheykill)\
**Post date:** [January 14, 2008, 4:02am UTC](https://www.ruby-forum.com/t/mysql-gem-on-64-bit-solaris-wont-compile/125952/1 "2008-01-14T04:02:56Z")

</div>

Hi all,

Solaris 10 x86 on a 64-bit Xenon server… Can anyone guess where this  
is going?

root@hostname:~# gem install mysql –  
–with-mysql-config=/usr/local/mysql/bin/mysql\_config  
Building native extensions. This could take a while…  
ERROR: Error installing mysql:  
ERROR: Failed to build gem native extension.

/usr/local/bin/ruby extconf.rb install mysql –  
–with-mysql-config=/usr/local/mysql/bin/mysql\_config  
checking for mysql\_ssl\_set()… no  
checking for mysql.h… yes  
creating Makefile

make  
gcc -I. -I. -I/usr/local/lib/ruby/1.8/i386-solaris2.10 -I.  
-DHAVE\_MYSQL\_H -I/usr/local/include -I/usr/X11R6/include  
-I/usr/local/ssl/include -I/usr/local/include/ncurses  
-I/usr/local/BerkeleyDB.4.2/include -I/usr/openwin/include  
-I/usr/local/mysql/include -m64 -mtune=k8 -fPIC -O2 -fpic -c mysql.c

gcc -shared -fPIC -L/usr/local/lib -R/usr/local/lib -R/usr/lib  
-L/usr/lib -R/usr/openwin/lib -L/usr/openwin/lib -L/usr/local/ssl/lib  
-R/usr/local/ssl/lib -L/usr/local/BerkeleyDB.4.2/lib  
-R/usr/local/BerkeleyDB.4.2/lib -L/usr/X11R6/lib -R/usr/X11R6/lib  
-L’/usr/local/lib’ -Wl,-R’/usr/local/lib’ -o mysql.so mysql.o -m64 -O2  
-mtune=k8 -static-libgcc -L/usr/local/mysql/lib -lmysqlclient -lz  
-lposix4 -lresolv -lgen -lsocket -lnsl -lm -ldl -lcrypt -lm -lc  
ld: fatal: file /usr/lib/libcrypt.so: wrong ELF class: ELFCLASS32  
ld: fatal: File processing errors. No output written to mysql.so  
collect2: ld returned 1 exit status  
\*\*\* Error code 1  
make: Fatal error: Command failed for target `mysql.so’

Gem files will remain installed in  
/usr/local/lib/ruby/gems/1.8/gems/mysql-2.7 for inspection.  
Results logged to  
/usr/local/lib/ruby/gems/1.8/gems/mysql-2.7/gem\_make.out  
root@hostname:~#

Of course make is barfing on my 32 bit libcrypt…

root@hostname:~# file /usr/lib/libcrypt.so  
/usr/lib/libcrypt.so: ELF 32-bit LSB dynamic lib 80386 Version 1,  
dynamically linked, not stripped, no debugging information available

root@hostname:~# file  
/usr/local/lib/ruby/gems/1.8/gems/mysql-2.7/mysql.o  
/usr/local/lib/ruby/gems/1.8/gems/mysql-2.7/mysql.o: ELF 64-bit LSB  
relocatable AMD64 Version 1

root@hostname:~# file /usr/local/mysql/lib/libmysqlclient.so  
/usr/local/mysql/lib/libmysqlclient.so: ELF 64-bit LSB dynamic lib AMD64  
Version 1, dynamically linked, not stripped, no debugging information  
available

I am assuming all this is happening because the Solaris package of MySQL  
that I installed (from [mysql.com](http://mysql.com)) is a 64 bit package…

Short of reinstalling MySQL as a 32 bit app, (which I would prefer not  
to do) can anyone make any suggestions? I started trying to recompile  
all kinds of so everything would match and got into a cycle of one thing  
depending on something else, depending on something until I broke ruby,  
gem, and half the system.

Thanks in advance,  
Andrew

---

<div class="post-metadata">

**Author:** ![armstheykill](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@armstheykill](https://www.ruby-forum.com/u/armstheykill)\
**Post date:** [January 14, 2008, 5:21am UTC](https://www.ruby-forum.com/t/mysql-gem-on-64-bit-solaris-wont-compile/125952/2 "2008-01-14T05:21:47Z")

</div>

Hi, I’m new to this group, but is it possible to put some sort of header  
on the subject line, etc. that denotes this as a [ruby-talk] group, so  
that I can set my e-mail up to automatically file these discussions  
under a Ruby folder? It is difficult to sort out these e-mails from  
SPAM. Or if someone else has a method of doing this on Thunderbird,  
that would be much appreciated.

Thanks,

Andrew O. wrote:

> -I/usr/local/BerkeleyDB.4.2/include -I/usr/openwin/include  
> ld: fatal: File processing errors. No output written to mysql.so
> 
> all kinds of so everything would match and got into a cycle of one thing  
> depending on something else, depending on something until I broke ruby,  
> gem, and half the system.
> 
> Thanks in advance,  
> Andrew

–  
Stephen D.  
President/CEO  
Virtual DSP Corporation  
4119 125th St SE  
Everett, WA 98208  
Tel 425.379.8888  
Fax 425.357.0567  
[http://www.virtual-dsp.com](http://www.virtual-dsp.com)

---

<div class="post-metadata">

**Author:** ![armstheykill](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@armstheykill](https://www.ruby-forum.com/u/armstheykill)\
**Post date:** [January 14, 2008, 8:36am UTC](https://www.ruby-forum.com/t/mysql-gem-on-64-bit-solaris-wont-compile/125952/3 "2008-01-14T08:36:25Z")

</div>

Quoth Steve D.:

> Hi, I’m new to this group, but is it possible to put some sort of header  
> on the subject line, etc. that denotes this as a [ruby-talk] group, so  
> that I can set my e-mail up to automatically file these discussions  
> under a Ruby folder? It is difficult to sort out these e-mails from  
> SPAM. Or if someone else has a method of doing this on Thunderbird,  
> that would be much appreciated.

You can filter by the To field of the mails. All mailing list stuff  
ought to  
be To: “ruby-talk ML” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid). There are other headers  
you  
could filter on:

- List-Post: [mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
- X-ML-Name: ruby-talk

No, we won’t be adding [ruby-talk] to the subject, this has been  
discussed  
before and you can learn more in the archives.

HTH,

---

<div class="post-metadata">

**Author:** ![armstheykill](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@armstheykill](https://www.ruby-forum.com/u/armstheykill)\
**Post date:** [January 14, 2008, 6:42pm UTC](https://www.ruby-forum.com/t/mysql-gem-on-64-bit-solaris-wont-compile/125952/4 "2008-01-14T18:42:43Z")

</div>

- Andrew O. (removed\_email\_address@domain.invalid) wrote:

> Solaris 10 x86 on a 64-bit Xenon server… Can anyone guess where this  
> is going?

It’s _Xeon_. Every time you say Xenon an Intel marketing team member  
kills himself. Hm… carry on.

> \*\*\* Error code 1  
> make: Fatal error: Command failed for target `mysql.so’

> Of course make is barfing on my 32 bit libcrypt…
> 
> root@hostname:~# file /usr/lib/libcrypt.so  
> /usr/lib/libcrypt.so: ELF 32-bit LSB dynamic lib 80386 Version 1,  
> dynamically linked, not stripped, no debugging information available

This looks like a Solaris bug:

[http://bugs.opensolaris.org/view\_bug.do?bug\_id=6531439](http://bugs.opensolaris.org/view_bug.do?bug_id=6531439)

If the workaround described there doesn’t work you might try getting the  
mysql extension tarball and messing about with extconf (maybe  
–with-mysql-lib=/usr/lib/amd64? ugh) and/or the Makefile.

You might also try strace/dtrace to see where the linker’s looking for  
the library first, in case that workaround is incomplete.

---

<div class="post-metadata">

**Author:** ![armstheykill](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@armstheykill](https://www.ruby-forum.com/u/armstheykill)\
**Post date:** [January 15, 2008, 9:55pm UTC](https://www.ruby-forum.com/t/mysql-gem-on-64-bit-solaris-wont-compile/125952/5 "2008-01-15T21:55:12Z")

</div>

You’re mixing 32-bit and 64-bit libraries.

Maybe Ruby is a 32-bit program and mysql.so is a 64-bit shared object.

---

<div class="post-metadata">

**Author:** ![armstheykill](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@armstheykill](https://www.ruby-forum.com/u/armstheykill)\
**Post date:** [January 18, 2008, 2:38pm UTC](https://www.ruby-forum.com/t/mysql-gem-on-64-bit-solaris-wont-compile/125952/6 "2008-01-18T14:38:35Z")

</div>

Gerardo S. GÃ³mez Garrido wrote:

> You’re mixing 32-bit and 64-bit libraries.
> 
> Maybe Ruby is a 32-bit program and mysql.so is a 64-bit shared object.

Well, yes, apparently this is true.

My MySQL installation is 64 bit, and so as a result so are its  
libraries.

andrewo@host:/opt/mysql/mysql/lib\> file libmysqlclient.so  
libmysqlclient.so: ELF 64-bit LSB dynamic lib AMD64 Version 1,  
dynamically linked, not stripped, no debugging information available

My Ruby installation is, indeed, a 32 bit install. That’s how the  
package I installed compiled it. I tried changing that by recompiling  
in 64 bit mode early in this whole saga, but it was an absolute  
nightmare. I don’t think the make files of most of the Ruby libraries  
play nicely with 64 bit compile options.

I suppose I could install the libraries from a 32bit MySQL installation  
and rebuild the gem based on those…

Any other ideas?

---

<div class="post-metadata">

**Author:** ![armstheykill](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@armstheykill](https://www.ruby-forum.com/u/armstheykill)\
**Post date:** [January 15, 2008, 7:22am UTC](https://www.ruby-forum.com/t/mysql-gem-on-64-bit-solaris-wont-compile/125952/7 "2008-01-15T07:22:49Z")

</div>

Thomas H. wrote:

> - Andrew O. (removed\_email\_address@domain.invalid) wrote:
> 
> > Solaris 10 x86 on a 64-bit Xenon server… Can anyone guess where this  
> > is going?
> 
> It’s _Xeon_. Every time you say Xenon an Intel marketing team member  
> kills himself. Hm… carry on.

Oops, I mean I meant to do that, I mean oops… }:0

> This looks like a Solaris bug:
> 
> [http://bugs.opensolaris.org/view\_bug.do?bug\_id=6531439](http://bugs.opensolaris.org/view_bug.do?bug_id=6531439)
> 
> If the workaround described there doesn’t work you might try getting the  
> mysql extension tarball and messing about with extconf (maybe  
> –with-mysql-lib=/usr/lib/amd64? ugh) and/or the Makefile.
> 
> You might also try strace/dtrace to see where the linker’s looking for  
> the library first, in case that workaround is incomplete.

Yuck.

This is a nudge in the right direction. I was monkeying around with the  
libraries mentioned in the bug report, (originally all of them existed  
in some form, dunno if links or files) and ln’ed when I meant to ls and  
lost track of what I was doing. Strangely enough, it compiled without a  
hitch immediately thereafter.

Sadly, it still doesn’t work…

andrewo@host:~/test# script/console  
Loading development environment.

> > require ‘mysql’  
> > LoadError: ld.so.1: ruby: fatal:  
> > /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7/lib/mysql.so: wrong ELF  
> > class: ELFCLASS64 -  
> > /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7/lib/mysql.so  
> > from /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7/lib/mysql.so

I’ll keep messing with it.

Thanks for the help.

---

<div class="post-metadata">

**Author:** ![armstheykill](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@armstheykill](https://www.ruby-forum.com/u/armstheykill)\
**Post date:** [January 18, 2008, 4:35pm UTC](https://www.ruby-forum.com/t/mysql-gem-on-64-bit-solaris-wont-compile/125952/8 "2008-01-18T16:35:05Z")

</div>

Andrew O. wrote:

> Gerardo S. GÃ³mez Garrido wrote:
> 
> > You’re mixing 32-bit and 64-bit libraries.  
> > My MySQL installation is 64 bit, and so as a result so are its  
> > libraries.
> 
> My Ruby installation is, indeed, a 32 bit install. That’s how the  
> package I installed compiled it. I tried changing that by recompiling  
> in 64 bit mode early in this whole saga, but it was an absolute  
> nightmare. I don’t think the make files of most of the Ruby libraries  
> play nicely with 64 bit compile options.
> 
> I suppose I could install the libraries from a 32bit MySQL installation  
> and rebuild the gem based on those…

I tried this as well. I got the MySQL libraries off a Solaris x86 32  
bit machine and copied over to my 64 bit machine. But after installing  
the gem, the mysql.so is still 64 bit.

root@trinity:/opt/mysql/mysql/lib/32# file libmysqlclient.so  
libmysqlclient.so: ELF 32-bit LSB dynamic lib 80386 Version 1,  
dynamically linked, not stripped

root@trinity:/opt/mysql/mysql/lib/32# gem install mysql –  
–with-mysql-config=/usr/local/mysql/bin/mysql\_config  
–with-mysql-lib=/usr/local/mysql/lib/32  
Building native extensions. This could take a while…  
Successfully installed mysql-2.7  
1 gem installed

root@trinity:/opt/mysql/mysql/lib/32# file  
/usr/local/lib/ruby/gems/1.8/gems/mysql-2.7/lib/mysql.so  
/usr/local/lib/ruby/gems/1.8/gems/mysql-2.7/lib/mysql.so: ELF  
64-bit LSB dynamic lib AMD64 Version 1, dynamically linked, not  
stripped, no debugging information available  
root@trinity:/opt/mysql/mysql/lib/32#

I’m about to give up and just reinstall mysql in 32 bit mode, but I  
don’t want to give up whatever little speed edge I’m getting from the 64  
bit version. I can’t be the first person to use sunfreeware ruby with  
official mysql…

---

<div class="post-metadata">

**Author:** ![armstheykill](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@armstheykill](https://www.ruby-forum.com/u/armstheykill)\
**Post date:** [January 18, 2008, 7:53pm UTC](https://www.ruby-forum.com/t/mysql-gem-on-64-bit-solaris-wont-compile/125952/9 "2008-01-18T19:53:43Z")

</div>

You have to tell Solaris where are the 32-bit libraries and the 64-bit  
libraries. There are three environment variables for this purpose:

LD\_LIBRARY\_PATH  
LD\_LIBRARY\_PATH\_32  
LD\_LIBRARY\_PATH\_64

Since the 32-bit MySQL libraries are the exception, set  
LD\_LIBRARY\_PATH\_32 to /usr/local/mysql/lib/32 and leave your  
LD\_LIBRARY\_PATH as it is, if you have one.
