Ruby on rails 如何解决在尝试使用ruby 2.3.8 | Rails 3.2.22.5 | Amazon Linux 2018.03安装rmagick gem时缺少libgomp.spec的问题

Ruby on rails 如何解决在尝试使用ruby 2.3.8 | Rails 3.2.22.5 | Amazon Linux 2018.03安装rmagick gem时缺少libgomp.spec的问题,ruby-on-rails,gcc,rmagick,amazon-linux,Ruby On Rails,Gcc,Rmagick,Amazon Linux,尝试在Amazon Linux版本2018.03上安装rmagick时出错 在yum之后安装ImageMagick 试图gem安装rmagick会导致以下错误。任何rmagic gem版本都会发生这种情况 Amazon Linux version: 2018.03 AMI Profile: base https://aws.amazon.com/amazon-linux-ami/2018.03-release-notes/ [user@ip-x-x-x-x]$ gem

尝试在Amazon Linux版本2018.03上安装rmagick时出错

yum之后安装ImageMagick

试图
gem安装rmagick
会导致以下错误。任何rmagic gem版本都会发生这种情况

    Amazon Linux version: 2018.03
    AMI Profile: base
    https://aws.amazon.com/amazon-linux-ami/2018.03-release-notes/

[user@ip-x-x-x-x]$ gem install rmagick

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

current directory: /home/user/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/rmagick-4.0.0/ext/RMagick
/home/user/.rbenv/versions/2.3.8/bin/ruby -r ./siteconf20200310-7185-ka0l3b.rb extconf.rb
checking for brew... no
checking for pacman... no
checking for gcc... yes
checking for pkg-config... yes
checking for outdated ImageMagick version (<= 6.7.7)... no
checking for __GNUC__... *** 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.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/home/user/.rbenv/versions/2.3.8/bin/$(RUBY_BASE_NAME)
/home/user/.rbenv/versions/2.3.8/lib/ruby/2.3.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /home/user/.rbenv/versions/2.3.8/lib/ruby/2.3.0/mkmf.rb:571:in `block in try_compile'
    from /home/user/.rbenv/versions/2.3.8/lib/ruby/2.3.0/mkmf.rb:524:in `with_werror'
    from /home/user/.rbenv/versions/2.3.8/lib/ruby/2.3.0/mkmf.rb:571:in `try_compile'
    from /home/user/.rbenv/versions/2.3.8/lib/ruby/2.3.0/mkmf.rb:835:in `macro_defined?'
    from /home/user/.rbenv/versions/2.3.8/lib/ruby/2.3.0/mkmf.rb:974:in `block in have_macro'
    from /home/user/.rbenv/versions/2.3.8/lib/ruby/2.3.0/mkmf.rb:942:in `block in checking_for'
    from /home/user/.rbenv/versions/2.3.8/lib/ruby/2.3.0/mkmf.rb:350:in `block (2 levels) in postpone'
    from /home/user/.rbenv/versions/2.3.8/lib/ruby/2.3.0/mkmf.rb:320:in `open'
    from /home/user/.rbenv/versions/2.3.8/lib/ruby/2.3.0/mkmf.rb:350:in `block in postpone'
    from /home/user/.rbenv/versions/2.3.8/lib/ruby/2.3.0/mkmf.rb:320:in `open'
    from /home/user/.rbenv/versions/2.3.8/lib/ruby/2.3.0/mkmf.rb:346:in `postpone'
    from /home/user/.rbenv/versions/2.3.8/lib/ruby/2.3.0/mkmf.rb:941:in `checking_for'
    from /home/user/.rbenv/versions/2.3.8/lib/ruby/2.3.0/mkmf.rb:973:in `have_macro'
    from extconf.rb:119:in `configure_compile_options'
    from extconf.rb:19:in `initialize'
    from extconf.rb:361:in `new'
    from extconf.rb:361:in `<main>'

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

  /home/user/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0-static/rmagick-4.0.0/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /home/user/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/rmagick-4.0.0 for inspection.
Results logged to /home/user/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0-static/rmagick-4.0.0/gem_make.out
Amazon Linux版本:2018.03
AMI配置文件:基本
https://aws.amazon.com/amazon-linux-ami/2018.03-release-notes/
[user@ip-x-x-x-x]$gem安装rmagick
构建本机扩展。这可能需要一段时间。。。
错误:安装rmagick时出错:
错误:无法生成gem本机扩展。
当前目录:/home/user/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0/gems/rmagick-4.0.0/ext/rmagick
/home/user/.rbenv/versions/2.3.8/bin/ruby-r./siteconf20200310-7185-ka0l3b.rb extconf.rb
正在检查brew。。。不
正在检查pacman。。。不
正在检查gcc。。。对
正在检查pkg配置。。。对

检查是否存在过时的ImageMagick版本(libgomp.spec文件在预期位置不可用。要解决此问题,我们必须将gcc 6.4.1中的
libgomp.spec
符号链接到
/usr/lib64/
目录

ln -s /usr/lib/gcc/x86_64-amazon-linux/6.4.1/libgomp.spec /usr/lib64/libgomp.spec
ln -s /usr/lib/gcc/x86_64-amazon-linux/6.4.1/libgomp.a /usr/lib64/libgomp.a
ln -s /usr/lib64/libgomp.so.1.0.0 /usr/lib64/libgomp.so
感谢@3D0G从本帖获得解决方案:

添加此问题/答案,以便更容易找到有关rmagick gem安装问题的解决方案

ln -s /usr/lib/gcc/x86_64-amazon-linux/6.4.1/libgomp.spec /usr/lib64/libgomp.spec
ln -s /usr/lib/gcc/x86_64-amazon-linux/6.4.1/libgomp.a /usr/lib64/libgomp.a
ln -s /usr/lib64/libgomp.so.1.0.0 /usr/lib64/libgomp.so