libgd icon indicating copy to clipboard operation
libgd copied to clipboard

Missing libgd when building gem native extension

Open josemigallas opened this issue 3 years ago • 2 comments

In our Rails project we want to use the gem local-fastimage_resize which requires libgd. According to the doc (and the Internet) it should be possible to install it by means of homebrew but when we try to install the gem it can't find the library.

Here are some logs from my M1 mac:

$ brew info libgd
==> gd: stable 2.3.3 (bottled), HEAD
Graphics library to dynamically manipulate images
https://libgd.github.io/
/opt/homebrew/Cellar/gd/2.3.3_3 (33 files, 1.5MB) *
  Poured from bottle on 2022-10-10 at 12:18:49
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/gd.rb
License: Cannot Represent
==> Dependencies
Required: fontconfig ✔, freetype ✔, jpeg-turbo ✔, libavif ✔, libpng ✔, libtiff ✔, webp ✔
==> Options
--HEAD
	Install HEAD version
==> Analytics
install: 147,026 (30 days), 503,823 (90 days), 1,624,252 (365 days)
install-on-request: 17,867 (30 days), 55,417 (90 days), 144,616 (365 days)
build-error: 0 (30 days)
$ gem install local-fastimage_resize -- --with-gdlib=/opt/homebrew/Cellar/gd/2.3.3_3
Building native extensions with: '--with-gdlib=/opt/homebrew/Cellar/gd/2.3.3_3'
This could take a while...
ERROR:  Error installing local-fastimage_resize:
	ERROR: Failed to build gem native extension.

    current directory: /Users/jgallaso/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/gems/local-fastimage_resize-3.4.0/ext/fastimage_native_resize
/Users/jgallaso/.asdf/installs/ruby/2.6.8/bin/ruby -I /Users/jgallaso/.asdf/installs/ruby/2.6.8/lib/ruby/2.6.0 -r ./siteconf20221010-18826-otaeca.rb extconf.rb --with-gdlib\=/opt/homebrew/Cellar/gd/2.3.3_3
checking for -l/opt/homebrew/Cellar/gd/2.3.3_3... no
missing libgd
*** 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=/Users/jgallaso/.asdf/installs/ruby/2.6.8/bin/$(RUBY_BASE_NAME)
	--with-gdlib

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

  /Users/jgallaso/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/extensions/arm64-darwin-21/2.6.0/local-fastimage_resize-3.4.0/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/jgallaso/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/gems/local-fastimage_resize-3.4.0 for inspection.
Results logged to /Users/jgallaso/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/extensions/arm64-darwin-21/2.6.0/local-fastimage_resize-3.4.0/gem_make.out

I've also tried installing libgd manually following instructions in INSTALL but no matter the path --with-gdlib it will return the same error.

Any ideas? 😖

josemigallas avatar Oct 10 '22 10:10 josemigallas

probably want to ask the ruby or homebrew folks for help instead

vapier avatar Oct 10 '22 10:10 vapier

gem install local-fastimage_resize -- --with-opt-dir=$(brew --prefix gd) worked for me

jkraemer avatar Jan 10 '23 10:01 jkraemer