Nek
Nek

Reputation: 3105

PHP extension imagick 3.5.0 for PHP 8 : installation on macos fails

When I try to run the following command

pecl install imagick

Then the installation end up with:

imagemagick/7.0.11-9/lib -L/usr/local/Cellar/imagemagick/7.0.11-9/lib -lMagickWand-7.Q16HDRI -lMagickCore-7.Q16HDRI
cc ${wl}-flat_namespace ${wl}-undefined ${wl}suppress -o .libs/imagick.so -bundle  .libs/imagick_file.o .libs/imagick_class.o .libs/imagickdraw_class.o .libs/imagickpixel_class.o .libs/imagickpixeliterator_class.o .libs/imagick_helpers.o .libs/imagick.o .libs/imagickkernel_class.o .libs/shim_im6_to_im7.o  -lgomp -L/usr/local/Cellar/imagemagick/7.0.11-9/lib /usr/local/Cellar/imagemagick/7.0.11-9/lib/libMagickWand-7.Q16HDRI.dylib -L/usr/local/Cellar/little-cms2/2.12/lib -L/usr/local/opt/freetype/lib -L/usr/local/Cellar/glib/2.68.1/lib -L/usr/local/opt/gettext/lib /usr/local/Cellar/imagemagick/7.0.11-9/lib/libMagickCore-7.Q16HDRI.dylib  -Wl,-rpath -Wl,/usr/local/Cellar/imagemagick/7.0.11-9/lib
ld: library not found for -lgomp
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [imagick.la] Error 1
ERROR: `make' failed

The reason seems to be that the compilation of the last version of imagick (3.5.0) has changes that require this library. It's impossible to install a lower version because they are not compatible with PHP 8.0.

Any idea how to get rid of this error on macos?

Upvotes: 3

Views: 13269

Answers (3)

Nek
Nek

Reputation: 3105

A new version has been tag and contains the build configuration fixed! You can install it with this command:

pecl install imagick-3.5.1

(without the version it should now work)

Upvotes: 0

Andrea Olivato
Andrea Olivato

Reputation: 2545

Update 22 July 2021

As of 22 July 2021, version 3.5.1 is stable in the pecl channel and can be used to compile imagick for both PHP 7 and PHP 8.

pecl install imagick

The general command will not fail anymore

Old Answer

Version 3.5 currently can't compile on MAC because of missing/broken support for gomp of the MAC gcc compiler.

Best fix is to install version 3.4.4

pecl install imagick-3.4.4

More info here

Upvotes: 7

Nicholas Gooding Rios
Nicholas Gooding Rios

Reputation: 533

There is a fix for this issue by manually installing the extension. The only issue with it is that it does not appear in the pecl installed extensions after the installation is done and can't be uninstalled from pecl. Nonetheless I'm providing the answer I found here:

Run the following commands

cd path/to/installation/is/going/to/be/made
pecl bundle imagick
cd imagick
mv config.m4 config.m4.bak
wget https://raw.githubusercontent.com/yyongpil/imagick/2a2b924b9d25c8ef4a677b72e6868fbc7c9e01cc/config.m4

To explain the previous process command line by command line:

  1. Place yourself in the folder where you are going to make the install
  2. Download and expand the source files
  3. Enter the source folder
  4. Backup the original config.m4 file for safety purposes
  5. Download modified config.m4 file to fix gomp issue as explained here

And finally simply continue with the manual installation process

phpize
./configuration
make
sudo make install

After this, you should be good to go to use the latest imagick extension for PHP. For PHP 8.0 and imagick 3.5.0 the so file is located at /usr/local/lib/php/pecl/20200930/imagick.so

Upvotes: 0

Related Questions