# Ruby gem install mysql compile error

**URL:** <https://www.ruby-forum.com/t/ruby-gem-install-mysql-compile-error/184518>\
**Category:** Ruby\
**Created:** [March 3, 2010, 8:02pm UTC](https://www.ruby-forum.com/t/ruby-gem-install-mysql-compile-error/184518 "2010-03-03T20:02:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ajmccauley](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f04885/32.png) [@ajmccauley](https://www.ruby-forum.com/u/ajmccauley)\
**Post date:** [March 3, 2010, 8:02pm UTC](https://www.ruby-forum.com/t/ruby-gem-install-mysql-compile-error/184518/1 "2010-03-03T20:02:10Z")

</div>

I am having an issue installing the mysql gem on my fedora 11 ruby  
1.9.1p376 installation.

mysql is installed and working. When I try to run sudo gem install mysql  
I get the following message:

Building native extensions. This could take a while…  
ERROR: Error installing mysql:  
ERROR: Failed to build gem native extension.

/usr/local/bin/ruby19 extconf.rb  
checking for mysql\_ssl\_set()… yes  
checking for rb\_str\_set\_len()… yes  
checking for rb\_thread\_start\_timer()… no  
checking for mysql.h… yes  
creating Makefile

make  
gcc -I. -I/usr/local/include/ruby19-1.9.1/x86\_64-linux  
-I/usr/local/include/ruby19-1.9.1/ruby/backward  
-I/usr/local/include/ruby19-1.9.1 -I. -DHAVE\_MYSQL\_SSL\_SET  
-DHAVE\_RB\_STR\_SET\_LEN -DHAVE\_MYSQL\_H -I/usr/local -I/usr/include/mysql  
-g -pipe -Wp,-D\_FORTIFY\_SOURCE=2 -fexceptions -fstack-protector  
–param=ssp-buffer-size=4 -m64 -D\_GNU\_SOURCE -D\_FILE\_OFFSET\_BITS=64  
-D\_LARGEFILE\_SOURCE -fno-strict-aliasing -fwrapv -fPIC -DUNIV\_LINUX  
-fPIC -O2 -g -Wall -Wno-parentheses -o mysql.o -c mysql.c  
gcc -shared -o mysql\_api.so mysql.o -L. -L/usr/local/lib  
-Wl,-R/usr/local/lib -L. -L/usr/local -rdynamic -Wl,-export-dynamic  
-rdynamic -L/usr/lib64/mysql -lmysqlclient -lz -lcrypt -lnsl -lm -lssl  
-lcrypto -lpthread -lrt -ldl -lcrypt -lm -lc  
/usr/bin/ld: /usr/local/lib/libssl.a(t1\_srvr.o): relocation R\_X86\_64\_32  
against `.data’ can not be used when making a shared object; recompile  
with -fPIC  
/usr/local/lib/libssl.a: could not read symbols: Bad value  
collect2: ld returned 1 exit status  
make: \*\*\* [mysql\_api.so] Error 1

Gem files will remain installed in  
/usr/local/lib/ruby19/gems/1.9.1/gems/mysql-2.8.1 for inspection.  
Results logged to  
/usr/local/lib/ruby19/gems/1.9.1/gems/mysql-2.8.1/ext/mysql\_api/gem\_make.out

I am not sure what I am doing wrong here any ideas would be appreciated.  
I tried downloading the source and get the same error when I enter make.

---

<div class="post-metadata">

**Author:** ![ajmccauley](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f04885/32.png) [@ajmccauley](https://www.ruby-forum.com/u/ajmccauley)\
**Post date:** [March 3, 2010, 9:30pm UTC](https://www.ruby-forum.com/t/ruby-gem-install-mysql-compile-error/184518/2 "2010-03-03T21:30:35Z")

</div>

On Mar 3, 8:02 pm, Aj Mccauley [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> /usr/local/bin/ruby19 extconf.rb  
> -DHAVE\_RB\_STR\_SET\_LEN -DHAVE\_MYSQL\_H -I/usr/local -I/usr/include/mysql  
> with -fPIC  
> I tried downloading the source and get the same error when I enter make.  
> Reading the error once again:

/usr/bin/ld: /usr/local/lib/libssl.a(t1\_srvr.o): relocation  
R\_X86\_64\_32  
against `.data’ can not be used when making a shared object;  
recompile  
with -fPIC  
/usr/local/lib/libssl.a: could not read symbols: Bad value

Seems clear to me: there is an issue with libssl (OpenSSL) installed  
in your system.

I cannot provide more help because I’m not familiarized with Fedora,  
but looks like like the library is not prepared to link with Ruby 1.9,  
and is mentioning recompilation with -fPIC option.

Anyone encountered similar issue?

---

<div class="post-metadata">

**Author:** ![ajmccauley](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f04885/32.png) [@ajmccauley](https://www.ruby-forum.com/u/ajmccauley)\
**Post date:** [March 3, 2010, 10:53pm UTC](https://www.ruby-forum.com/t/ruby-gem-install-mysql-compile-error/184518/3 "2010-03-03T22:53:28Z")

</div>

> You built your own openssl rather than using the Fedora packages?

I did build openssl-0.9.8l from source. In hind sight, it would have  
been a better idea to just use yum…

---

<div class="post-metadata">

**Author:** ![ajmccauley](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f04885/32.png) [@ajmccauley](https://www.ruby-forum.com/u/ajmccauley)\
**Post date:** [March 3, 2010, 10:33pm UTC](https://www.ruby-forum.com/t/ruby-gem-install-mysql-compile-error/184518/4 "2010-03-03T22:33:48Z")

</div>

On Wed, Mar 3, 2010 at 2:02 PM, Aj Mccauley [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> collect2: ld returned 1 exit status  
> make: \*\*\* [mysql\_api.so] Error 1

/usr/local/lib/libssl.a  
You built your own openssl rather than using the Fedora packages?

---

<div class="post-metadata">

**Author:** ![ajmccauley](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f04885/32.png) [@ajmccauley](https://www.ruby-forum.com/u/ajmccauley)\
**Post date:** [March 4, 2010, 2:51am UTC](https://www.ruby-forum.com/t/ruby-gem-install-mysql-compile-error/184518/5 "2010-03-04T02:51:21Z")

</div>

> > You built your own openssl rather than using the Fedora packages?
> 
> I did build openssl-0.9.8l from source. In hind sight, it would have  
> been a better idea to just use yum…

I just rebuilt the server and used the Fedora packaged openssl and it  
seems to be working fine! Thanks for the help in pointing me in the  
right direction.
