在Ubuntu 16.04LTS

时间:2016-09-28 03:04:49

标签: ruby-on-rails ruby ubuntu-16.04 mysql2

我试过sudo gem install mysql2 -v'0.4.4'并且出错了。检查/var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/mysql2-0.4.4/mkmf.log:

"gcc -o conftest -I/usr/include/x86_64-linux-gnu/ruby-2.3.0 -I/usr/include/ruby-2.3.0/ruby/backward -I/usr/include/ruby-2.3.0 -I. -Wdate-time -D_FORTIFY_SOURCE=2   -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -fPIC conftest.c  -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic     -lruby-2.3  -lpthread -lgmp -ldl -lcrypt -lm   -lc"
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

所以在我看来ruby.h就是问题所在。但我可以在:

找到它
/usr/include/ruby-2.3.0/ruby/ruby.h
/usr/include/ruby-2.3.0/ruby.h

我检查了Error while installing json gem 'mkmf.rb can't find header files for ruby',但事实上我已经安装了ruby开发。

sudo dpkg -l | grep ruby​​也表明我有:

sudo dpkg -l | grep ruby
ii  libruby2.3:amd64                      2.3.1-2~16.04                     amd64        Libraries necessary to run Ruby 2.3
ii  rake                                  10.5.0-2                          all          ruby make-like utility
ii  ruby                                  1:2.3.0+1                         all          Interpreter of object-oriented scripting language Ruby (default version)
ii  ruby-bundler                          1.11.2-1                          all          Manage Ruby application dependencies (runtime)
ii  ruby-dev:amd64                        1:2.3.0+1                         amd64        Header files for compiling extension modules for Ruby (default version)
ii  ruby-did-you-mean                     1.0.0-2                           all          smart error messages for Ruby > 2.3
ii  ruby-eventmachine                     1.0.7-3build3                     amd64        Ruby/EventMachine library
ii  ruby-minitest                         5.8.4-2                           all          Ruby test tools supporting TDD, BDD, mocking, and benchmarking
ii  ruby-molinillo                        0.4.3-1                           all          generic dependency resolution algorithm
ii  ruby-mysql                            2.9.1-1ubuntu1                    amd64        MySQL module for Ruby
ii  ruby-mysql2                           0.4.3-2ubuntu2                    amd64        simple, fast MySQL library for Ruby
ii  ruby-net-http-persistent              2.9.4-1                           all          Manages persistent connections using Net::HTTP
ii  ruby-net-telnet                       0.1.1-2                           all          telnet client library
ii  ruby-power-assert                     0.2.7-1                           all          library showing values of variables and method calls in an expression
ii  ruby-test-unit                        3.1.7-2                           all          unit testing framework for Ruby
ii  ruby-thor                             0.19.1-2                          all          Ruby scripting framework
ii  ruby2.3                               2.3.1-2~16.04                     amd64        Interpreter of object-oriented scripting language Ruby
ii  ruby2.3-dev:amd64                     2.3.1-2~16.04                     amd64        Header files for compiling extension modules for the Ruby 2.3
ii  rubygems-integration                  1.10                              all          integration of Debian Ruby packages with Rubygems

那么我该如何解决这个问题呢?

1 个答案:

答案 0 :(得分:2)

尝试安装gcc和make。这项工作适合我。

apt-get install gcc make