---
title: "gem安装mysql2 出现编译问题"
author: "夜鸣猪"
date: "2012-05-21T21:44:41Z"
tags: []
categories: ["编程语言"]
slug: "gem-mysql2"
draft: false
lastmod: "2012-11-22T13:07:34Z"
id: 1536952
url: "https://hlee.iteye.com/blog/1536952"
---

```java
sudo apt-get install libmysql-ruby libmysqlclient-dev
```



> 
> Installing mysql2 (0.3.11) with native extensions 
> Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
> 
>         /home/livegamer/.rvm/rubies/ruby-1.9.3-p125/bin/ruby extconf.rb 
> checking for rb_thread_blocking_region()... yes
> checking for rb_wait_for_single_fd()... yes
> 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... no
> checking for main() in -lsocket... no
> checking for mysql_query() in -lmysqlclient... no
> checking for main() in -lnsl... yes
> checking for mysql_query() in -lmysqlclient... no
> checking for main() in -lmygcc... no
> checking for mysql_query() in -lmysqlclient... no
> *** extconf.rb failed ***
> Could not create Makefile due to some reason, probably lack of
> necessary libraries and/or headers.  Check the mkmf.log file for more
> details.  You may need configuration options.
> 
> 


ubuntu 下要确认

```shell

sudo aptitude install mysql-server-5.5 mysql-client-5.5



sudo aptitude install libmysqlclient-dev
```