webp-ffi: Error installing on Macbook with Apple Silicon

Logs while installing gem install webp-ffi

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

    current directory: /Users/htgyl/.rvm/gems/ruby-2.5.1/gems/webp-ffi-0.2.7/ext/webp_ffi
/Users/htgyl/.rvm/rubies/ruby-2.5.1/bin/ruby -rrubygems /Users/htgyl/.rvm/gems/ruby-2.5.1/gems/rake-12.3.2/exe/rake
RUBYARCHDIR\=/Users/htgyl/.rvm/gems/ruby-2.5.1/extensions/-darwin-20/2.5.0/webp-ffi-0.2.7
RUBYLIBDIR\=/Users/htgyl/.rvm/gems/ruby-2.5.1/extensions/-darwin-20/2.5.0/webp-ffi-0.2.7
mkdir -p aarch64-darwin
gcc -fexceptions -O -fno-omit-frame-pointer -fno-strict-aliasing -arch x86_64 -DHAVE_PUTS=1 -DHAVE_WEBPDECODERCONFIG=1 -DHAVE_WEBPGETINFO=1 -DHAVE_STDIO_H=1
-o aarch64-darwin/jpegdec.o -c ./jpegdec.c
In file included from ./jpegdec.c:1:
././jpegdec.h:3:10: fatal error: 'webp/encode.h' file not found
#include "webp/encode.h"
         ^~~~~~~~~~~~~~~
1 error generated.
rake aborted!
Command failed with status (1): [gcc -fexceptions -O -fno-omit-frame-pointe...]
/Users/htgyl/.rvm/gems/ruby-2.5.1/gems/ffi-compiler-1.0.1/lib/ffi-compiler/compile_task.rb:133:in `block (2 levels) in define_task!'
/Users/htgyl/.rvm/gems/ruby-2.5.1/gems/rake-12.3.2/exe/rake:27:in `<main>'
Tasks: TOP => default => aarch64-darwin/libwebp_ffi.bundle => aarch64-darwin/jpegdec.o
(See full trace by running task with --trace)

rake failed, exit code 1

After specifying the paths for CPATH export CPATH="/opt/homebrew/include/" Getting the following errors.

    current directory: /Users/htgyl/.rvm/gems/ruby-2.5.1/gems/webp-ffi-0.2.7/ext/webp_ffi
/Users/htgyl/.rvm/rubies/ruby-2.5.1/bin/ruby -rrubygems /Users/htgyl/.rvm/gems/ruby-2.5.1/gems/rake-12.3.2/exe/rake
RUBYARCHDIR\=/Users/htgyl/.rvm/gems/ruby-2.5.1/extensions/-darwin-20/2.5.0/webp-ffi-0.2.7
RUBYLIBDIR\=/Users/htgyl/.rvm/gems/ruby-2.5.1/extensions/-darwin-20/2.5.0/webp-ffi-0.2.7
mkdir -p aarch64-darwin
gcc -fexceptions -O -fno-omit-frame-pointer -fno-strict-aliasing -arch x86_64 -DHAVE_PUTS=1 -DHAVE_WEBPDECODERCONFIG=1 -DHAVE_WEBPGETINFO=1 -DHAVE_STDIO_H=1
-o aarch64-darwin/jpegdec.o -c ./jpegdec.c
gcc -fexceptions -O -fno-omit-frame-pointer -fno-strict-aliasing -arch x86_64 -DHAVE_PUTS=1 -DHAVE_WEBPDECODERCONFIG=1 -DHAVE_WEBPGETINFO=1 -DHAVE_STDIO_H=1
-o aarch64-darwin/pngdec.o -c ./pngdec.c
gcc -fexceptions -O -fno-omit-frame-pointer -fno-strict-aliasing -arch x86_64 -DHAVE_PUTS=1 -DHAVE_WEBPDECODERCONFIG=1 -DHAVE_WEBPGETINFO=1 -DHAVE_STDIO_H=1
-o aarch64-darwin/tiffdec.o -c ./tiffdec.c
gcc -fexceptions -O -fno-omit-frame-pointer -fno-strict-aliasing -arch x86_64 -DHAVE_PUTS=1 -DHAVE_WEBPDECODERCONFIG=1 -DHAVE_WEBPGETINFO=1 -DHAVE_STDIO_H=1
-o aarch64-darwin/util.o -c ./util.c
gcc -fexceptions -O -fno-omit-frame-pointer -fno-strict-aliasing -arch x86_64 -DHAVE_PUTS=1 -DHAVE_WEBPDECODERCONFIG=1 -DHAVE_WEBPGETINFO=1 -DHAVE_STDIO_H=1
-o aarch64-darwin/webp_ffi.o -c ./webp_ffi.c
gcc -bundle -o aarch64-darwin/libwebp_ffi.bundle aarch64-darwin/jpegdec.o aarch64-darwin/pngdec.o aarch64-darwin/tiffdec.o aarch64-darwin/util.o
aarch64-darwin/webp_ffi.o -fexceptions -arch x86_64 -lz -lwebp -lpng -ljpeg -ltiff
ld: library not found for -lwebp
clang: error: linker command failed with exit code 1 (use -v to see invocation)
rake aborted!
Command failed with status (1): [gcc -bundle -o aarch64-darwin/libwebp_ffi....]
/Users/htgyl/.rvm/gems/ruby-2.5.1/gems/ffi-compiler-1.0.1/lib/ffi-compiler/compile_task.rb:153:in `block in define_task!'
/Users/htgyl/.rvm/gems/ruby-2.5.1/gems/rake-12.3.2/exe/rake:27:in `<main>'
Tasks: TOP => default => aarch64-darwin/libwebp_ffi.bundle
(See full trace by running task with --trace)

rake failed, exit code 1

Any other paths i have to define?

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 32 (15 by maintainers)

Most upvoted comments

To make the screenshot above accessible:

export CPATH=/opt/homebrew/include/
export LIBRARY_PATH=$LIBRARY_PATH:/opt/homebrew/lib/
gem install webp-ffi -v 0.3.1

Problem resolved in version 0.3.1

This does not have to do with M1 as much as it has to do with Big Sur. With the later versions of MacOS, they seemed to have stopped using /usr/local/include/.

thank you so much, I just confuse the two image extensions in my message. I had already done the same for libpng and that gives me the same errors.

So I tried to update a lot of things around, in particular xcode, but also a lot of libraries around. Then postgresql stopped to work when starting a rails server. No way to start psql server.

After that I reinstalled postgresql and redone all the steps and finally the gem was installed. Later I’ll try it and enjoy your awesome gem.

thanks again for the support

After specifying the valid paths, 0.3.1 version worked for me as well. Thanks @0x962 & @le0pard

image

Fetching webp-ffi-0.3.1.gem
Building native extensions. This could take a while...
Successfully installed webp-ffi-0.3.1
Parsing documentation for webp-ffi-0.3.1
Installing ri documentation for webp-ffi-0.3.1
Done installing documentation for webp-ffi after 0 seconds
1 gem installed

Thank you! 😃