리눅스 서버 TIP

리눅스 에서 gem 설치하는 도중에 checking for ffi.h... *** extconf.rb failed *** 발생시 조치 방법

작성자 정보

  • 작성자 HKEBI
  • 작성일

컨텐츠 정보

본문

 리눅스에서 gem 설치 하다가 아래처럼 에러가 발생 할때가 있습니다.

제가 해보다가 안되어서 해결하면서 남겨 놓으니 참고 하세요 ^^

 

root@namgyeong-t440s:/var/www/html# gem install listen --version 2.7.0

Fetching listen-2.7.0.gem

Fetching nio4r-2.5.2.gem

Fetching celluloid-io-0.17.3.gem

Building native extensions. This could take a while...

ERROR:  Error installing listen:

ERROR: Failed to build gem native extension.


    current directory: /var/lib/gems/2.7.0/gems/ffi-1.13.1/ext/ffi_c

/usr/bin/ruby2.7 -I /usr/lib/ruby/2.7.0 -r ./siteconf20200825-75004-c3wr9p.rb extconf.rb

checking for ffi.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}/lib

--with-make-prog

--without-make-prog

--srcdir=.

--curdir

--ruby=/usr/bin/$(RUBY_BASE_NAME)2.7

--with-ffi_c-dir

--without-ffi_c-dir

--with-ffi_c-include

--without-ffi_c-include=${ffi_c-dir}/include

--with-ffi_c-lib

--without-ffi_c-lib=${ffi_c-dir}/lib

--enable-system-libffi

--disable-system-libffi

--with-libffi-config

--without-libffi-config

--with-pkg-config

--without-pkg-config

--with-ffi-dir

--without-ffi-dir

--with-ffi-include

--without-ffi-include=${ffi-dir}/include

--with-ffi-lib

--without-ffi-lib=${ffi-dir}/lib

/usr/lib/ruby/2.7.0/mkmf.rb:471:in `try_do': The compiler failed to generate an executable file. (RuntimeError)

You have to install development tools first.

from /usr/lib/ruby/2.7.0/mkmf.rb:613:in `try_cpp'

from /usr/lib/ruby/2.7.0/mkmf.rb:1124:in `block in have_header'

from /usr/lib/ruby/2.7.0/mkmf.rb:971:in `block in checking_for'

from /usr/lib/ruby/2.7.0/mkmf.rb:361:in `block (2 levels) in postpone'

from /usr/lib/ruby/2.7.0/mkmf.rb:331:in `open'

from /usr/lib/ruby/2.7.0/mkmf.rb:361:in `block in postpone'

from /usr/lib/ruby/2.7.0/mkmf.rb:331:in `open'

from /usr/lib/ruby/2.7.0/mkmf.rb:357:in `postpone'

from /usr/lib/ruby/2.7.0/mkmf.rb:970:in `checking_for'

from /usr/lib/ruby/2.7.0/mkmf.rb:1123:in `have_header'

from extconf.rb:10:in `system_libffi_usable?'

from extconf.rb:42:in `<main>'


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


  /var/lib/gems/2.7.0/extensions/x86_64-linux/2.7.0/ffi-1.13.1/mkmf.log


extconf failed, exit code 1


Gem files will remain installed in /var/lib/gems/2.7.0/gems/ffi-1.13.1 for inspection.

Results logged to /var/lib/gems/2.7.0/extensions/x86_64-linux/2.7.0/ffi-1.13.1/gem_make.out


 

이런 에러가 발생 하는데 mkmf.log 파일을 열어보니 stdio.h 가 없어서 컴파일이 안되는거네요. 


root@namgyeong-t440s:/var/www/html# more /var/lib/gems/2.7.0/extensions/x86_64-linux/2.7.0/ffi-1.13.1/mkmf.log

"pkg-config --exists libffi"

package configuration for libffi is not found

"gcc -o conftest -I/usr/include/x86_64-linux-gnu/ruby-2.7.0 -I/usr/include/ruby-2.7.0/ruby/backward -I/usr/include/ruby-2.7.0 -I. -Wdate-time -D_FORTIFY_SOURCE=2   -g -O2 -fdebug-prefix-

map=/build/ruby2.7-3CyDhe/ruby2.7-2.7.0=. -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-strong -rdynamic -Wl,-export-dynamic     -lruby-2.7  -lm   -lc"

In file included from /usr/include/ruby-2.7.0/ruby/ruby.h:29,

                 from /usr/include/ruby-2.7.0/ruby.h:33,

                 from conftest.c:1:

/usr/include/ruby-2.7.0/ruby/defines.h:126:10: fatal error: stdio.h: No such file or directory

  126 | #include <stdio.h>

      |          ^~~~~~~~~

compilation terminated.

checked program was:

/* begin */

1: #include "ruby.h"

2: 

3: int main(int argc, char **argv)

4: {

5:   return !!argv[argc];

6: }

/* end */

 

확인해 보니 libc6-dev 가 없어서 그렇다고 하네요. 

그래서 그냥 libc6-dev  만 설치되면 문제가 해결이 됩니다. 


root@namgyeong-t440s:/var/www/html# dpkg -l |grep -i libc6

ii  libc6:amd64                                   2.31-0ubuntu9                               amd64        GNU C Library: Shared libraries

ii  libc6:i386                                    2.31-0ubuntu9                               i386         GNU C Library: Shared libraries

ii  libc6-dbg:amd64                               2.31-0ubuntu9                               amd64        GNU C Library: detached debugging symbols

rc  libc6-i386                                    2.23-0ubuntu9                               amd64        GNU C Library: 32-bit shared libraries for AMD64

root@namgyeong-t440s:/var/www/html# sudo apt-get install libc6-dev

Reading package lists... Done

Building dependency tree       

Reading state information... Done

The following packages were automatically installed and are no longer required:

  libfprint-2-tod1 libllvm9 libllvm9:i386 libplymouth5

 

그러고나니 gem 설치에 전혀 문제가 없네요 ^^

혹시 비슷한 문제로 고민 하시고 계시다면 참고 하세요~~


관련자료

댓글 0
등록된 댓글이 없습니다.

공지글


동영상


최근글


새댓글


포인트 랭킹


COUNT


오늘
67
어제
118
최대
186
전체
13,827