Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build fails on Ubuntu 16.04 #63

Open
okor opened this issue Jan 26, 2017 · 12 comments
Open

Build fails on Ubuntu 16.04 #63

okor opened this issue Jan 26, 2017 · 12 comments

Comments

@okor
Copy link

okor commented Jan 26, 2017

Similar to this issue from early 2015 #51 on Ubuntu 16.04, following the build instructions precisely (apt installs ImageMagick v6.8.9) building imgmin fails. Also worth noting I had to manually export MAGICK_CONFIG=/usr/lib/x86_64-linux-gnu/ImageMagick-6.8.9/bin-Q16/Magick-config or config/make would fail to find the config and would result in an error like --cflags: command not found since the MAGICK_CONFIG default value falls back to an empty string.

The error details:

root@1edbd36cf720:/root/imgmin-1.1# make
make  all-recursive
make[1]: Entering directory '/root/imgmin-1.1'
Making all in src
make[2]: Entering directory '/root/imgmin-1.1/src'
gcc -W -Wall -Os  `/usr/bin/GraphicsMagickWand-config --cflags --cppflags` -o imgmin imgmin.c dssim.c `/usr/bin/GraphicsMagickWand-config --ldflags --libs` -lm
imgmin.c:28:29: fatal error: wand/MagickWand.h: No such file or directory
compilation terminated.
dssim.c: In function ‘convert_image_row’:
dssim.c:304:55: warning: unused parameter ‘inf’ [-Wunused-parameter]
 static void convert_image_row(const dssim_info *const inf, float *const channels[], const int num_channels, const int y, const int width, void *user_data)
                                                       ^
Makefile:566: recipe for target 'imgmin' failed
make[2]: *** [imgmin] Error 1
make[2]: Leaving directory '/root/imgmin-1.1/src'
Makefile:355: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/root/imgmin-1.1'
Makefile:296: recipe for target 'all' failed
make: *** [all] Error 2

I'm using Docker, phusion/baseimage:0.9.19 which is ubuntu 16.04. Here's a minimal Dockerfile that will reproduce the issue:

FROM phusion/baseimage:0.9.19

# Use baseimage-docker's init system.
CMD [ /sbin/my_init ]

# upgrade
RUN apt-get update && apt-get dist-upgrade -y

# build tools (uninstall afterwards)
RUN apt-get install -y \
  build-essential \
  dh-autoreconf \
  wget

RUN apt-get install -y libpng-dev
RUN cd && wget https://github.com/pornel/pngquant/archive/2.5.0.tar.gz && \
  tar xf 2.5.0.tar.gz && \
  cd pngquant-2.5.0 && \
  make && \
  make install

RUN apt-get install -y imagemagick libgraphicsmagick1-dev libmagickwand-dev perlmagick libmagick++-6-headers libmagick++-dev
ENV MAGICK_CONFIG=/usr/bin/GraphicsMagickWand-config
RUN cd && wget https://github.com/rflynn/imgmin/archive/v1.1.tar.gz && \
  tar xf v1.1.tar.gz && \
  cd imgmin-1.1 && \
  autoreconf -fi && \
  ./configure && \
  make && \
  make install

You can build the image with docker build -t thumbor . when in a dir with the Dockerfile above.

It will fail but you can still shell in with docker run -t -i thumbor /sbin/my_init -- bash -l. After you shell in you'd probably want to rerun imgmin build step (it fails so it won't be in the image) with cd /root && wget https://github.com/rflynn/imgmin/archive/v1.1.tar.gz && \ tar xf v1.1.tar.gz && \ cd imgmin-1.1 && \ export MAGICK_CONFIG=/usr/bin/GraphicsMagickWand-config && autoreconf -fi && \ ./configure && \ make && \ make install

Would appreciate any help. Thanks.

@UmeshSingla
Copy link

@okor were you able to get around this?

@okor
Copy link
Author

okor commented Jun 18, 2017

@UmeshSingla Nope, I took a different approach since my use case was experimental anyways.

@Norrodar
Copy link

Norrodar commented Jan 4, 2018

Did someone found a solution?
(@rflynn )

@Enalmada
Copy link

Enalmada commented May 9, 2018

I was getting "fatal error: wand/MagickWand.h: No such file or directory" on ubuntu and just before giving up forever, I was able to get around it by installing ImageMagick from source (ImageMagick-7.0.7 ) based on the instructions in the prerequisite page and then doing the linker step (sudo ldconfig /usr/local/lib) and tests from actual instructions page making sure cmdline really works. Then restarting the imgmin build process from scratch seemed to actually finish.

@Enalmada Enalmada mentioned this issue May 9, 2018
@bagipriyank
Copy link

bagipriyank commented May 26, 2018

@Enalmada is that still working for you? it doesn't seem to be working for me.

this is what i am doing, please let me know if you are doing something different:

sudo wget -nH -nd ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick-7.0.7-35.tar.gz
sudo gzip -dc ImageMagick-7.0.7-35.tar.gz | sudo tar xvf -
cd ImageMagick-7.0.7-35
sudo ./configure
sudo make -j2
sudo make install
sudo ldconfig /usr/local/lib

wget https://github.com/rflynn/imgmin/archive/v1.1.tar.gz
tar xf v1.1.tar.gz
cd imgmin-1.1
autoreconf -fi
./configure
make
sudo make install

also tried these steps for just imgmin and it doesn't work either

wget https://github.com/rflynn/imgmin/archive/v1.1.tar.gz
tar xf v1.1.tar.gz
cd imgmin-1.1
make
sudo make install

@Enalmada
Copy link

Enalmada commented May 29, 2018

Well I went through my steps again from scratch and it didn't work so there must have been something mysterious I did during my frantic trying that I forgot about. Here are more precisely the steps I was following using AWS EC2 Ubuntu Server 16.04 LTS (HVM). I was installing imgmin as a prereq for thumbor auto plugin so something in those gist steps may have helped.

First make sure your ImageMagick is really installed and working by doing "make check" after installing it. (I just ran mine and got 79 pass and 7 fail...I don't remember any fail before which is concerning but hopefully in things imgmin doesn't care about).

I may have figured out a hack:

# Brutal hack to get imgmin installed
sudo apt-get install libmagickcore-dev libmagickwand-dev
mkdir /usr/local/include/magick
# find your magick-baseconfig.h
# find . / -name magick-baseconfig.h
cp /usr/local/include/ImageMagick-7/MagickCore/magick-baseconfig.h /usr/local/include/magick

sudo apt-get install -y autoconf pngnq pngcrush pngquant
git clone https://github.com/rflynn/imgmin.git
cd imgmin
autoreconf -fi
./configure
sudo C_INCLUDE_PATH=/usr/include/ImageMagick-6/ PKG_CONFIG_PATH=/opt/ImageMagick/lib/pkgconfig/ make
sudo make install 
# Make sure it works
time ./src/imgmin examples/Afghan-Girl-by-Steve-McCurry.jpg Afghan-Girl-by-Steve-McCurry-after.jpg

Sucks this is so hard to install...but it seems I did get it going again finally using first the steps in the gist I posted and then the hacked steps above (copy some baseconfig file and then make install using somee C_INCLUDE_PATH and PKG_CONFIG_PATH prefix). I am just guessing that the real problem might be imgmin needs imgmagick 6 instead of 7 and installing the latest is a bad idea...my hack above seems to work around that but it would be better if someone could update imgmin to build with 7. Or perhaps we all just need to install the last version of imgmagick 6. Hopefully this helps....

@gdarko
Copy link

gdarko commented May 29, 2018

@Enalmada on my end it fails because of this one

make[3]: Entering directory '/root/imgmin/src/apache2'
if [ "apxs2" != "" ]; then
apxs2 -I pwd/.. /usr/lib/x86_64-linux-gnu/ImageMagick-6.9.7/bin-q16/MagickWand-config --cppflags --ldflags --libs|xargs|sed "s/-fopenmp\s//" -Wc,-DIMGMIN_LIB -Wc,-W -Wc,-Wall -Wc,-Wno-unused-parameter -c mod_imgmin.c ../imgmin.c ../dssim.c;
fi
apxs:Error: Unknown option: f.


So the error must be into that line but i still have to debug it i don't really understand what they are doing here.

@Enalmada
Copy link

Enalmada commented May 29, 2018

@gdarko Unfortunately I never saw that error, only a MagickWand.h and magick-baseconfig.h not found errors. Note that I was starting with AWS EC2 Ubuntu Server 16.04 LTS (HVM), following the gist for some other image libraries, then the C_INCLUDE/PKG hack to get around the not found errors.

I see an open ticket with a similar looking issue: #21. It looks like there might be some solutions talked about/linked to the ticket. It is a long shot but you could try uninstalling apache before trying to build. Otherwise I would just have to say I am pretty confident anyone can get imgmin working on a vanilla AWS EC2 Ubuntu with the hack above but it would be nice if someone with build experience could update the scripts so the hack isn't required (which I assume is updating them to reference a newer imagemagick and beyond my abilities).

@bagipriyank
Copy link

@Enalmada even with your suggestion I get

imgmin.c:28:29: fatal error: wand/MagickWand.h: No such file or directory
 #include <wand/MagickWand.h>
                             ^
compilation terminated.
dssim.c: In function ‘convert_image_row’:
dssim.c:304:55: warning: unused parameter ‘inf’ [-Wunused-parameter]
 static void convert_image_row(const dssim_info *const inf, float *const channels[], const int num_channels, const int y, const int width, void *user_data)
                                                       ^
Makefile:554: recipe for target 'imgmin' failed
make[2]: *** [imgmin] Error 1
make[2]: Leaving directory '/usr/src/app/imgmin-1.1/src'
Makefile:344: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/usr/src/app/imgmin-1.1'
Makefile:284: recipe for target 'all' failed
make: *** [all] Error 2

The thing is, the location of MagickWand.h has changed.

root@df81bbb2e540:~/imgmin-1.1# ls -lh /usr/local/include/ImageMagick-7/MagickWand/
total 128K
-rw-r--r-- 1 root staff 3.8K May 29 20:40 MagickWand.h
-rw-r--r-- 1 root staff  968 May 29 20:40 animate.h
-rw-r--r-- 1 root staff  968 May 29 20:40 compare.h
-rw-r--r-- 1 root staff  975 May 29 20:40 composite.h
-rw-r--r-- 1 root staff  967 May 29 20:40 conjure.h
-rw-r--r-- 1 root staff  967 May 29 20:40 convert.h
-rw-r--r-- 1 root staff 1.1K May 29 20:40 deprecate.h
-rw-r--r-- 1 root staff  967 May 29 20:40 display.h
-rw-r--r-- 1 root staff 9.3K May 29 20:40 drawing-wand.h
-rw-r--r-- 1 root staff  971 May 29 20:40 identify.h
-rw-r--r-- 1 root staff  963 May 29 20:40 import.h
-rw-r--r-- 1 root staff 1.2K May 29 20:40 magick-cli.h
-rw-r--r-- 1 root staff  19K May 29 20:40 magick-image.h
-rw-r--r-- 1 root staff 5.4K May 29 20:40 magick-property.h
-rw-r--r-- 1 root staff 4.2K May 29 20:40 method-attribute.h
-rw-r--r-- 1 root staff 1.5K May 29 20:40 mogrify.h
-rw-r--r-- 1 root staff  967 May 29 20:40 montage.h
-rw-r--r-- 1 root staff  923 May 29 20:40 operation.h
-rw-r--r-- 1 root staff 2.1K May 29 20:40 pixel-iterator.h
-rw-r--r-- 1 root staff 4.1K May 29 20:40 pixel-wand.h
-rw-r--r-- 1 root staff  964 May 29 20:40 stream.h
-rw-r--r-- 1 root staff 2.4K May 29 20:40 wand-view.h
-rw-r--r-- 1 root staff 1.5K May 29 20:40 wandcli.h
root@df81bbb2e540:~/imgmin-1.1#

@Enalmada
Copy link

Enalmada commented May 29, 2018

@bagipriyank Do you have a /usr/include/ImageMagick-6/wand/MagickWand.h? If not, I have no idea where that comes from but perhaps try "sudo apt-get install libmagickcore-dev libmagickwand-dev"...I got it from either that, being already installed in EC2 Ubuntu, imgmin prereq doc steps, or was put down by some line in the gist I followed before trying to install imgmin. So if all else fails, you may need to try EC2 Ubuntu and follow the gist steps I posted in comment above to get it. Once you get it, the C_INCLUDE_PATH part of this "sudo C_INCLUDE_PATH=/usr/include/ImageMagick-6/ PKG_CONFIG_PATH=/opt/ImageMagick/lib/pkgconfig/ make" should work around it. (Yes, the location has changed in 7 which I believe is the very root of this ticket so you gotta get /usr/include/ImageMagick-6 installed so you can hack the C_INCLUDE_PATH as a workaround until someone who knows what they are doing can change the script to use the location you posted). You might be able to copy ImageMagick-7/MagickWand to ImageMagick-7/wand....and use ImageMagick-7/ in C_INCLUDE_PATH but that is just guessing.

@bagipriyank
Copy link

bagipriyank commented May 29, 2018

that worked. thanks @Enalmada. I had to do "sudo apt-get install libmagickcore-dev libmagickwand-dev". that got the /usr/include/ImageMagick-6/wand/MagickWand.h

@Enalmada
Copy link

Enalmada commented May 29, 2018

@bagipriyank That is great news. So it seems libmagickcore-dev is probably what does it specifically since i see the libmagickwand-dev in the imgmin prereq already....I updated my comment steps. I hope others that want to use imgmin on ubuntu can get it working too now. I was lucky enough to stumble upon some stackoverflow with a C_INCLUDE_PATH hack about something unrelated and tried it out right before I gave up forever on imgmin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants