packetmonkey / prawn-gmagick

Use GraphcisMagick to load images into a Prawn document
https://github.com/packetmonkey/prawn-gmagick/
13 stars 6 forks source link

Can't get gem to install #9

Open chrislebaron opened 9 years ago

chrislebaron commented 9 years ago

I can't get this to install on Yosemite or Ubuntu, I get this error -

Building native extensions.  This could take a while...
ERROR:  Error installing prawn-gmagick:
ERROR: Failed to build gem native extension.

/Users/chrislebaron/.rvm/rubies/ruby-2.0.0-p598/bin/ruby -r ./siteconf20150420-89976-xlzogx.rb extconf.rb
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
compiling image.c
image.c:3:10: fatal error: 'wand/magick_wand.h' file not found
#include <wand/magick_wand.h>
     ^
1 error generated.
make: *** [image.o] Error 1

make failed, exit code 2
packetmonkey commented 9 years ago

I use the gem on both of those platforms, locally in development on Yosemite and in production on Ubuntu so I would expect it to build.

What does the output of GraphicsMagickWand-config --cflags --cppflags show?

chrislebaron commented 9 years ago

Oh thanks, I figured it out. I thought I only needed ImageMagick installed. I installed GraphicsMagick and it worked like a charm!

packetmonkey commented 9 years ago

Glad to hear, thanks for the follow-up.

nusdon commented 9 years ago

I have the same problem.

When i run command

`gem install prawn-gmagick -v '0.0.7'``

I get this error

Building native extensions.  This could take a while...
ERROR:  Error installing prawn-gmagick:
    ERROR: Failed to build gem native extension.

    /usr/bin/ruby20 extconf.rb
Usage: GraphicsMagickWand-config [--cflags] [--cppflags] [--exec-prefix] [--ldflags] [--libs] [--prefix] [--version]

 For example, "example.c" may be compiled to produce "example" as follows:

  "gcc -o example example.c `GraphicsMagickWand-config --cppflags --cflags --ldflags --libs`"
creating Makefile

make "DESTDIR="
compiling image.c
linking shared-object image.so
/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.4/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/local/lib64/libGraphicsMagick.a(magick_libGraphicsMagick_la-plasma.o): warning: relocation against `PlasmaImage' in readonly section `.text'.
/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.4/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/local/lib64/libGraphicsMagickWand.a(wand_libGraphicsMagickWand_la-magick_wand.o): relocation R_X86_64_PC32 against symbol `MagickCompareImageChannels' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.4/../../../../x86_64-pc-linux-gnu/bin/ld: final link failed: Bad value
collect2: ld returned 1 exit status
make: *** [image.so] Error 1

Output of GraphicsMagickWand-config --cflags --cppflags:

-fopenmp -g -O2 -Wall -pthread
-I/usr/local/include/GraphicsMagick
BenSwennen commented 9 years ago

Same issue here (above suggestions don't work):

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

    /Users/bensw/.rvm/rubies/ruby-2.1.5/bin/ruby -r ./siteconf20150720-5403-11ptpiz.rb extconf.rb 
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
compiling image.c
image.c:3:10: fatal error: 'wand/magick_wand.h' file not found
#include <wand/magick_wand.h>
         ^
1 error generated.
make: *** [image.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/bensw/.rvm/gems/ruby-2.1.5/gems/prawn-gmagick-0.0.8 for inspection.
Results logged to /Users/bensw/.rvm/gems/ruby-2.1.5/extensions/x86_64-darwin-14/2.1.0-static/prawn-gmagick-0.0.8/gem_make.out
An error occurred while installing prawn-gmagick (0.0.8), and Bundler cannot continue.
Make sure that `gem install prawn-gmagick -v '0.0.8'` succeeds before bundling.

Gemfile:

gem 'rmagick'
gem 'graphicsmagick'
gem "prawn-gmagick"
packetmonkey commented 9 years ago

@BenSmartcheckups What does the output of GraphicsMagickWand-config --cflags --cppflags show?

The error you and @chrislebaron where/are getting is from the compiler not being able to find the graphicsmagick header files.

@nusdon I'm not sure what is going on with your situation, it looks to be a problem with your linker but I don't think I have seen that error before. Not sure how to follow up on that.

I'll re-open this issue for now.

R-Campbell commented 9 years ago

I'm having a similar issue getting the gem to install on Heroku. The error I'm seeing is:

creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
compiling image.c
image.c:3:30: fatal error: wand/magick_wand.h: No such file or directory
#include <wand/magick_wand.h>
^
compilation terminated.
make: *** [image.o] Error 1
make failed, exit code 2

I've setup the multibuildpack:

https://github.com/ddollar/heroku-buildpack-multi

and my .buildpack file is:

https://github.com/stomita/heroku-buildpack-phantomjs
https://github.com/ello/heroku-buildpack-imagemagick-cedar-14
https://github.com/packetmonkey/heroku-buildpack-graphicsmagick
https://github.com/heroku/heroku-buildpack-ruby

I've tried both with the https://github.com/mcollina/heroku-buildpack-graphicsmagick as well as yours. I have been able to successfully deploy on Heroku with 'gem graphicsmagick' in the gemfile, but not 'gem prawn-gmagick'. Any suggestions would be greatly appreciated.

packetmonkey commented 9 years ago

In order to make it work on Heroku I had to do a custom fork of the ruby build pack and set some environment variables. I'll open a PR with Heroku to see about getting something like those changes merged so that isn't needed.

I would also recommended not relying on my graphicsmagick build pack, I should note it better but I don't intend that for public use, it's mostly for me to mess around with trying different library versions in a slug. I'll add a comment to the repo for that.

As a general rule if I have a non-heroku build pack I'm using I fork it and use my own copy so someone else doesn't make a possibly breaking change to my slug.

packetmonkey commented 9 years ago

Also I was able to reproduce the build problem suggesting -fPIC by trying to build the gem on a ubuntu system where I installed the latest version of GM from source. I don't have a fix yet but at least I see the problem.

Siyfion commented 9 years ago

I am also getting the same issue on my own development machine (OSX), with the following output:

Installing prawn-gmagick 0.0.8 with native extensions

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

    /usr/local/opt/ruby/bin/ruby -r ./siteconf20151007-18652-1r9n49h.rb extconf.rb
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
compiling image.c
image.c:3:10: fatal error: 'wand/magick_wand.h' file not found
#include <wand/magick_wand.h>
         ^
1 error generated.
make: *** [image.o] Error 1

make failed, exit code 2

Gem files will remain installed in /usr/local/lib/ruby/gems/2.2.0/gems/prawn-gmagick-0.0.8 for inspection.
Results logged to /usr/local/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-15/2.2.0/prawn-gmagick-0.0.8/gem_make.out
An error occurred while installing prawn-gmagick (0.0.8), and Bundler cannot continue.
Make sure that `gem install prawn-gmagick -v '0.0.8'` succeeds before bundling.
siyfion$ GraphicsMagickWand-config --cflags --cppflags
-g -O2 -Wall -D_THREAD_SAFE
-I/usr/local/Cellar/graphicsmagick/1.3.21/include/GraphicsMagick
Siyfion commented 9 years ago

Okay this is really weird, once I'd done a brew install ImageMagick pkg-configit worked... Now I can't seem to get it to fail, and I'm not sure which dependency that I've added has sorted it out!

However, now that I'm trying to get this working in an Elastic Beanstalk instance again, the same issue appears...

escobera commented 9 years ago

I'm having trouble to install this on heroku as well. @R-Campbell or @packetmonkey got to a solution?

packetmonkey commented 9 years ago

In order to get the gem to build on Heroku I had to fork a custom ruby build pack to set some environment variables so that the gem compilation could find the gmagick library that got added by a separate build pack. I am not sure of a good way to package that up for other people to use, and my initial discussion with Heroku on how to add that behavior to the standard ruby build pack didn't get far.

Here was that issue https://github.com/heroku/heroku-buildpack-ruby/issues/407

nzajt commented 7 years ago

I know this issue is old, but I had this issue on AMI linux, similar to Centos, and I needed to install GraphicsMagick-devel not just GraphicsMagick. sudo yum install GraphicsMagick-devel

amejiarosario commented 5 years ago

Yes, installing GraphicsMagick did the trick.

On Mac:

brew install GraphicsMagick
gem install prawn-gmagick

On Ubuntu/Debian:

sudo apt-get install -y build-essential libgraphicsmagick1-dev
sudo apt-get install -y graphicsmagick-imagemagick-compat graphicsmagick-libmagick-dev-compat 
elharion commented 5 years ago

I have exactly the same issue

image.c:3:10: fatal error: 'wand/magick_wand.h' file not found

I have installed properly imagemacik, pkgconfig, graphicsmagick throguh brew on macos 10.14.

$ GraphicsMagickWand-config --cflags --cppflags
-g -O2 -Wall -D_THREAD_SAFE
-I/usr/local/Cellar/graphicsmagick/1.3.21/include/GraphicsMagick

Any ideas what could be done? Reinstalls, brew link --force, adding paths didn't help :(

axelzito commented 5 years ago

Yes, installing GraphicsMagick did the trick.

On Mac:

brew install GraphicsMagick
gem install prawn-gmagick

On Ubuntu/Debian:

sudo apt-get install -y graphicsmagick-imagemagick-compat graphicsmagick-libmagick-dev-compat

That way solved for me, tks :)

abhianair commented 5 years ago

I have the same problem, How to debug in windows ???

abelsromero commented 4 years ago

For thos in Windows, I just installed MSYS with ridk as recommended then installed the appropiate package with ridk.cmd exec pacman -S mingw64/mingw-w64-x86_64-graphicsmagick, and after that I could install the gem without issues.

ajw1970 commented 3 years ago

For thos in Windows, I just installed MSYS with ridk as recommended then installed the appropiate package with ridk.cmd exec pacman -S mingw64/mingw-w64-x86_64-graphicsmagick

I'm getting this when I run that:

:: Retrieving packages... error: failed retrieving file 'mingw-w64-x86_64-libwinpthread-git-7.0.0.5447.a2d94c81-1-any.pkg.tar.xz' from repo.msys2.org : The requested URL returned error: 404 error: failed retrieving file 'mingw-w64-x86_64-libwinpthread-git-7.0.0.5447.a2d94c81-1-any.pkg.tar.xz' from sourceforge.net : Maximum file size exceeded error: failed retrieving file 'mingw-w64-x86_64-libwinpthread-git-7.0.0.5447.a2d94c81-1-any.pkg.tar.xz' from www2.futureware.at : The requested URL returned error: 404 error: failed retrieving file 'mingw-w64-x86_64-libwinpthread-git-7.0.0.5447.a2d94c81-1-any.pkg.tar.xz' from mirror.yandex.ru : The requested URL returned error: 404 warning: failed to retrieve some files

heridev commented 3 years ago

For those of you trying to install this on a Heroku 20 app, maybe this can work for you as well: https://stackoverflow.com/questions/66843301/error-installing-prawn-gmagick-within-heroku-stack-20-due-to-invalid-wand-magick

ajw1970 commented 3 years ago

Problem installing in Ubunto 20.04 Ruby 2.7.2p137


$ sudo gem install prawn-gmagick Building native extensions. This could take a while... ERROR: Error installing prawn-gmagick: ERROR: Failed to build gem native extension.

current directory: /var/lib/gems/2.7.0/gems/prawn-gmagick-0.0.9/ext/image

/usr/bin/ruby2.7 -I /usr/lib/ruby/2.7.0 -r ./siteconf20210913-6172-14fi7n6.rb extconf.rb creating Makefile

current directory: /var/lib/gems/2.7.0/gems/prawn-gmagick-0.0.9/ext/image make "DESTDIR=" clean sh: 1: make: not found

current directory: /var/lib/gems/2.7.0/gems/prawn-gmagick-0.0.9/ext/image make "DESTDIR=" sh: 1: make: not found

make failed, exit code 127

Gem files will remain installed in /var/lib/gems/2.7.0/gems/prawn-gmagick-0.0.9 for inspection. Results logged to /var/lib/gems/2.7.0/extensions/x86_64-linux/2.7.0/prawn-gmagick-0.0.9/gem_make.out


$ GraphicsMagickWand-config --cflags --cppflags -fopenmp -g -O2 -fdebug-prefix-map=/build/graphicsmagick-7OaGZU/graphicsmagick-1.4+really1.3.35=. -fstack-protector-strong -Wformat -Werror=format-security -Wall -pthread -I/usr/include/GraphicsMagick

abelsromero commented 3 years ago

@ajw1970 the message points to make not being available, you'll need to install that and probably other dependencies with apt.

ajw1970 commented 3 years ago

@ajw1970 the message points to make not being available, you'll need to install that and probably other dependencies with apt.

Thank you. I'm quite new to Linux and quite rusty with Unix.

packetmonkey commented 3 years ago

On ubuntu you will probably need the build-essential package to get utilities like make and gcc, then the development package for graphicsmagick, I believe it was called libgraphicsmagick1-dev. I believe those two packages should allow you to build the gem.

ajw1970 commented 3 years ago

On ubuntu you will probably need the build-essential package to get utilities like make and gcc, then the development package for graphicsmagick, I believe it was called libgraphicsmagick1-dev. I believe those two packages should allow you to build the gem.

Thank you. Installing make did the trick but I installed build-essential too just now to avoid any future issues.

vizcay commented 3 years ago

On ubuntu 20.04 needed to install graphicsmagick-imagemagick-compat graphicsmagick-libmagick-dev-compat, just libgraphicsmagick1-dev was not enough.

reitzig commented 1 year ago

For reference, in Alpine:

# docker run --rm -it asciidoctor/docker-asciidoctor bash
# apk add imagemagick graphicsmagick
apk add gcc musl-dev ruby-dev imagemagick-dev graphicsmagick-dev
gem install prawn-gmagick

I suspect that after that, we can remove the dev dependencies by

apk del gcc musl-dev ruby-dev imagemagick-dev graphicsmagick-dev

and retain a working setup, but I have not tested that.

StigerHe commented 1 year ago

For thos in Windows, I just installed MSYS with ridk as recommended then installed the appropiate package with ridk.cmd exec pacman -S mingw64/mingw-w64-x86_64-graphicsmagick, and after that I could install the gem without issues.

latest Ruby and MSYS2, need use ridk.cmd exec pacman -S mingw64/mingw-w64-curt-x86_64-graphicsmagick.

because it uses curt64 instead of mingw64.

packetmonkey commented 1 year ago

I'm going to close this issue as it's very old and touches on a lot of different platforms. If you wish to open a PR that documents how to install the gem on a specific platform I would consider it.