Error while attempting to install rmagick on an Amazon Linux Version 2018.03
After yum install ImageMagick
attempting gem install rmagick
causes the following error. This happens with any rmagic gem version.
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
The additional information within the rmagick 4.0.0 mkmf.rb
find_executable: checking for brew... -------------------- no
--------------------
find_executable: checking for pacman... -------------------- no
--------------------
find_executable: checking for gcc... -------------------- yes
--------------------
find_executable: checking for pkg-config... -------------------- yes
--------------------
configure_compile_options: checking for outdated ImageMagick version (<= 6.7.7)... -------------------- no
Detected ImageMagick version: 6.7.8
--------------------
"gcc -o conftest -I/home/user/.rbenv/versions/2.3.8/include/ruby-2.3.0/x86_64-linux -I/home/user/.rbenv/versions/2.3.8/include/ruby-2.3.0/ruby/backward -I/home/user/.rbenv/versions/2.3.8/include/ruby-2.3.0 -I. -fopenmp -I/usr/include/ImageMagick -fopenmp -I/usr/include/ImageMagick conftest.c -L. -L/home/user/.rbenv/versions/2.3.8/lib -Wl,-rpath,/home/user/.rbenv/versions/2.3.8/lib -lMagickCore -lMagickCore -Wl,-rpath,/home/user/.rbenv/versions/2.3.8/lib -L/home/user/.rbenv/versions/2.3.8/lib -lruby-static -lpthread -ldl -lcrypt -lm -lc"
gcc: error: libgomp.spec: No such file or directory
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */
The libgomp.spec file is not available in the expected location. To resolve this issue we had to symlink the libgomp.spec
from gcc 6.4.1 into the /usr/lib64/
directory
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
Thank you to @3D0G for the solution from this post:
gcc: error: libgomp.spec: No such file or directory with Amazon Linux 2017.09.1
Adding this question / answer for easier finding of the solution in regards to the issue with rmagick gem installation.