Mô tả

Khi cài đặt Redmine có một option là cài đặt thư viện rmagick.
Thư viện rmagick này có thể được cài đặt bằng command sau:

$ gem install rmagick -v 2.16.0

Tuy nhiên khi chạy command trên thì xuất hiện lỗi:

Fetching: rmagick-2.16.0.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing rmagick:
        ERROR: Failed to build gem native extension.

    current directory: /usr/local/share/ruby/gems/2.3/gems/rmagick-2.16.0/ext/RMagick
/usr/bin/ruby2.3 -r ./siteconf20181116-31766-ujshus.rb extconf.rb
checking for gcc... yes
checking for Magick-config... yes

Warning: Found a partial ImageMagick installation. Your operating system likely has some built-in ImageMagick libraries but not all of ImageMagick. This will most likely cause problems at both compile and runtime.
Found partial installation at: /usr
checking for outdated ImageMagick version (<= 6.4.9)... no
checking for presence of MagickWand API (ImageMagick version >= 6.9.0)... no
checking for Ruby version >= 1.8.5... yes
checking for stdint.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.

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}/lib64
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=/usr/bin/$(RUBY_BASE_NAME)2.3
/usr/share/ruby/2.3/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
        from /usr/share/ruby/2.3/mkmf.rb:587:in `try_cpp'
        from /usr/share/ruby/2.3/mkmf.rb:1091:in `block in have_header'
        from /usr/share/ruby/2.3/mkmf.rb:942:in `block in checking_for'
        from /usr/share/ruby/2.3/mkmf.rb:350:in `block (2 levels) in postpone'
        from /usr/share/ruby/2.3/mkmf.rb:320:in `open'
        from /usr/share/ruby/2.3/mkmf.rb:350:in `block in postpone'
        from /usr/share/ruby/2.3/mkmf.rb:320:in `open'
        from /usr/share/ruby/2.3/mkmf.rb:346:in `postpone'
        from /usr/share/ruby/2.3/mkmf.rb:941:in `checking_for'
        from /usr/share/ruby/2.3/mkmf.rb:1090:in `have_header'
        from extconf.rb:39:in `configure_headers'
        from extconf.rb:18:in `initialize'
        from extconf.rb:548:in `new'
        from extconf.rb:548:in `<main>'

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

  /usr/local/lib64/ruby/gems/2.3/gems/rmagick-2.16.0/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /usr/local/share/ruby/gems/2.3/gems/rmagick-2.16.0 for inspection.
Results logged to /usr/local/lib64/ruby/gems/2.3/gems/rmagick-2.16.0/gem_make.out

Lần theo nội dung file log ở đường dẫn /usr/local/lib64/ruby/gems/2.3/gems/rmagick-2.16.0/mkmf.log thì được lỗi:

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 */

Vậy là thiếu thư viện libgomp.spec nên gcc không thể complile được.

Thử cài đặt yum install libgomp.x86_64 thì nhận được thông báo là thư viện này đã được cài đặt.

Giải pháp

Sau khi tìm kiếm một hồi trên Google thì có được thông tin là có thể các file của thư viện libgomp chưa có trong $PATH.

OK, tạo symbolic link như bên dưới là giải quyết được.

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

Chú ý: thư mục 4.8.5 có thể thay đổi tùy thuộc vào phiên bản Amazon Linux đang sử dụng.