magick-rust icon indicating copy to clipboard operation
magick-rust copied to clipboard

Fail to build

Open worikgh opened this issue 1 year ago • 1 comments

On Debian 12 I cloned the repository and ran cargo build`

magick-rust$ PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig cargo build

I get the error:

  thread 'main' panicked at build.rs:288:10:
  called `Result::unwrap()` on an `Err` value: 
  pkg-config exited with status code 1
  > PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 pkg-config --libs --cflags MagickWand MagickWand >= 7.0

  The system library `MagickWand` required by crate `magick_rust` was not found.
  The file `MagickWand.pc` needs to be installed and the PKG_CONFIG_PATH environment variable must contain its parent directory.
  PKG_CONFIG_PATH contains the following:
      - /usr/lib/x86_64-linux-gnu/pkgconfig

But:

magick-rust$ ls -l /usr/lib/x86_64-linux-gnu/pkgconfig/MagickWand.pc 
lrwxrwxrwx 1 root root 21 Feb 13 09:15 /usr/lib/x86_64-linux-gnu/pkgconfig/MagickWand.pc -> MagickWand-im6.q16.pc
  • I have installed the available packages
magick-rust$ aptitude search magickwand
i A libmagickwand-6-headers                                                                           - image manipulation library - headers files                                                                 
v   libmagickwand-6.defaultquantum-dev                                                                -                                                                                                            
i A libmagickwand-6.q16-6                                                                             - image manipulation library -- quantum depth Q16                                                            
i A libmagickwand-6.q16-dev                                                                           - image manipulation library - development files (Q16)                                                       
i A libmagickwand-6.q16hdri-6                                                                         - image manipulation library -- quantum depth Q16HDRI                                                        
i   libmagickwand-6.q16hdri-dev                                                                       - image manipulation library - development files (Q16HDRI)                                                   
i   libmagickwand-dev                                                                                 - image manipulation library -- dummy package                                                                

worikgh avatar Apr 21 '24 23:04 worikgh

Unless you check out an older version of magick-rust, you will need to use ImageMagick version 7, which basically requires building it from source. Note that in order to load basically any images at all, you will need to install the requisite image libraries (e.g. libjpeg-dev, libpng-dev), otherwise you get the dreaded "failed to read file" error (ImageMagick return codes are 1 (good) or 0 (bad), so no help in debugging issues).

Here is how to get it compiled and tested. Note that this is a fresh install of bookworm in a VM, in which I install all prerequisites, including Rust and the image libraries:

sudo apt-get update
sudo apt-get install build-essential clang curl git pkg-config libjpeg-dev libjpeg-turbo-progs libpng-dev
wget https://imagemagick.org/archive/ImageMagick.tar.gz
tar axf ImageMagick.tar.gz
cd ImageMagick-7.1.1-31/
./configure --with-magick-plus-plus=no --with-perl=no
make
sudo make install
cd ..
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
. .cargo/env
git clone https://github.com/nlfiedler/magick-rust.git
cd magick-rust/
cargo build
cargo test

nlfiedler avatar Apr 23 '24 00:04 nlfiedler

Added an INSTALL.md guide that provides tested instructions for building on Ubunut Linux. The example above is slightly wrong, at least for Ubuntu 24.04 (replace libjpeg-turbo-progs with libjpeg-dev).

nlfiedler avatar May 25 '24 22:05 nlfiedler