Problems with compiling ImageMagick with HEIC

Hopefully me struggling for way too long getting mogrify up and running will help someone else.

Compiling imagemagick with HEIC support from clean install of Ubuntu:

$ sudo sed -Ei 's/^# deb-src /deb-src /' /etc/apt/sources.list
$ sudo apt-get update
$ sudo apt-get install build-essential autoconf git-core
$ sudo apt-get build-dep imagemagick libde265 libheif
$ cd /usr/src/ 
$ sudo git clone https://github.com/strukturag/libde265.git  
$ sudo git clone https://github.com/strukturag/libheif.git 
$ cd libde265/ 
$ sudo ./autogen.sh 
$ sudo ./configure 
$ sudo make –j4  
$ sudo make install 
$ cd /usr/src/libheif/ 
$ sudo ./autogen.sh 
$ sudo ./configure 
$ sudo make –j4  
$ sudo make install 
$ cd /usr/src/ 
$ sudo wget https://www.imagemagick.org/download/ImageMagick.tar.gz 
$ sudo tar xf ImageMagick.tar.gz 
$ cd ImageMagick-7* 
$ sudo ./configure --with-heic=yes 
$ sudo make –j4  
$ sudo make install  
$ sudo ldconfig  
$ mogrify --version 
# heic should appear in the Delegates line 

Additional References:

https://linuxconfig.org/how-to-install-imagemagick-7-on-ubuntu-18-04-linux

https://github.com/ImageMagick/ImageMagick/issues/1470

https://github.com/strukturag/libheif/blob/master/README.md

https://github.com/strukturag/libde265/blob/master/README.md


I had the same problem under Ubuntu 18.04 when trying to compile the latest version of ImageMagick 7.0.8. The solution was to manually compile and install the latest version of libheif from here. After this, the compilation succeeded. Remember to uninstall the default package of libheif supplied by Ubuntu first, both libheif and libheif-dev.