gpt4 book ai didi

linux - 构建 Gem native 扩展

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:47:07 24 4
gpt4 key购买 nike

Passing on knowledge I just learned in the hopes of reducing the headache others may experience with native gem extensions like I've had.

TL;DR - Had an issue with bundle install. Read mkmf.log as mentioned in the error. The log had another error that I googled. Installed necessary library. Afterwards, bundle install was successful.

尝试使用 bundler 安装 gem 并收到有关构建 gem native 扩展的错误:

$ bundle install
Fetching gem metadata from https://rubygems.org/...........
Fetching version metadata from https://rubygems.org/..
Resolving dependencies...
Installing daemons 1.2.3
Installing eventmachine 1.0.8 with native extensions

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory: /usr/local/rvm/gems/ruby-2.3.0/gems/eventmachine-1.0.8/ext
/usr/local/rvm/rubies/ruby-2.3.0/bin/ruby -r ./siteconf20160309-8483-1so3k75.rb extconf.rb
*** 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.

<...>

To see why this extension failed to compile, please check the mkmf.log which can be found here:

/usr/local/rvm/gems/ruby-2.3.0/extensions/x86_64-linux/2.3.0/eventmachine-1.0.8/mkmf.log

extconf failed, exit code 1

<...>
Installing mysql2 0.4.3 with native extensions

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory: /usr/local/rvm/gems/ruby-2.3.0/gems/mysql2-0.4.3/ext/mysql2
/usr/local/rvm/rubies/ruby-2.3.0/bin/ruby -r ./siteconf20160309-8483-1oxfnj5.rb extconf.rb
checking for ruby/thread.h... *** 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.

<...>

To see why this extension failed to compile, please check the mkmf.log which can be found here:

/usr/local/rvm/gems/ruby-2.3.0/extensions/x86_64-linux/2.3.0/mysql2-0.4.3/mkmf.log

extconf failed, exit code 1

<...>
Installing rack 1.6.4
Installing tilt 2.0.1
Using bundler 1.11.2
An error occurred while installing eventmachine (1.0.8), and Bundler cannot continue.
Make sure that `gem install eventmachine -v '1.0.8'` succeeds before bundling.

最佳答案

Passing on knowledge I just learned in the hopes of reducing the headache others may experience with native gem extensions like I've had.

TL;DR - Had an issue with bundle install. Read mkmf.log as mentioned in the error. The log had another error that I googled. Installed necessary library. Afterwards, bundle install was successful.

我看到错误将我指向 mkmf.log 及其所在位置。我打开它并检查错误。其中第 2 行和第 3 行提到了以下内容。

/usr/bin/ld: cannot find -lgmp
collect2: error: ld returned 1 exit status

我从 bundle install 期间的错误得知它可能缺少一个库。所以我搜索了一个名为 gmp 的包。我找到了 2 个库,一个名为 libgmp10,另一个名为 libgmp10-dev

$ apt-cache search -n gmp
libgmp-dev - Multiprecision arithmetic library developers tools
libgmp10 - Multiprecision arithmetic library
<...>

我搜索已安装的软件包,看是否需要安装一个。

$ dpkg --get-selections | grep gmp
libgmp10:amd64 install

由于 libgmp10 已经存在,我尝试安装 libgmp-dev。然后我运行重试安装我的 gem,它成功了!

$ sudo apt-get install libgmp-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
libgmpxx4ldbl
Suggested packages:
libgmp10-doc libmpfr-dev
The following NEW packages will be installed:
libgmp-dev libgmpxx4ldbl
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 300 kB of archives.
After this operation, 1,675 kB of additional disk space will be used.
Do you want to continue? [Y/n]
Get:1 http://us.archive.ubuntu.com/ubuntu/ trusty/main libgmpxx4ldbl amd64 2:5.1.3+dfsg-1ubuntu1 [8,736 B]
Get:2 http://us.archive.ubuntu.com/ubuntu/ trusty/main libgmp-dev amd64 2:5.1.3+dfsg-1ubuntu1 [292 kB]
Fetched 300 kB in 0s (411 kB/s)
Selecting previously unselected package libgmpxx4ldbl:amd64.
(Reading database ... 218685 files and directories currently installed.)
Preparing to unpack .../libgmpxx4ldbl_2%3a5.1.3+dfsg-1ubuntu1_amd64.deb ...
Unpacking libgmpxx4ldbl:amd64 (2:5.1.3+dfsg-1ubuntu1) ...
Selecting previously unselected package libgmp-dev:amd64.
Preparing to unpack .../libgmp-dev_2%3a5.1.3+dfsg-1ubuntu1_amd64.deb ...
Unpacking libgmp-dev:amd64 (2:5.1.3+dfsg-1ubuntu1) ...
Setting up libgmpxx4ldbl:amd64 (2:5.1.3+dfsg-1ubuntu1) ...
Setting up libgmp-dev:amd64 (2:5.1.3+dfsg-1ubuntu1) ...
Processing triggers for libc-bin (2.19-0ubuntu6.7) ...
$ bundle install
Fetching gem metadata from https://rubygems.org/...........
Fetching version metadata from https://rubygems.org/..
Resolving dependencies...
Using daemons 1.2.3
Installing eventmachine 1.0.8 with native extensions
Installing mysql2 0.4.3 with native extensions
Using rack 1.6.4
Using tilt 2.0.1
Using bundler 1.11.2
Installing rack-protection 1.5.3
Installing thin 1.6.4 with native extensions
Installing sinatra 1.4.6
Bundle complete! 3 Gemfile dependencies, 9 gems now installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.

关于linux - 构建 Gem native 扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35903960/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com