Closed apphancer closed 2 years ago
I think you should uninstall and re-install ImageMagick before trying to install imagick.
All of the error messages:
(/opt/homebrew/Cellar/imagemagick/7.1.0-16/lib/libMagickCore-7.Q16HDRI.10.dylib) was built for newer macOS version (12.0) than being linked (11.3)
Are about the ImageMagick libraries found on your system not having been compiled for your version of macOS.
Fixed by re-installing xcode. Thanks for the suggestion. I had already tried re-installing ImageMagick and ended up having to cleanup all of the brew packages as there was a mess since transferring everything from an Intel Mac to an Arm one. Apparently, xcode didn't get re-installed and that was the issue.
I can confirm everything is working using PHP 8.0 with an M1 CPU.
After re-installing xcode, I am still not able to get imagemagic to compile.
make
/bin/sh /Users/dan/work/ffw/projects/imagick/libtool --mode=link cc -DPHP_ATOM_INC -I/Users/dan/work/ffw/projects/imagick/include -I/Users/dan/work/ffw/projects/imagick/main -I/Users/dan/work/ffw/projects/imagick -I/opt/homebrew/Cellar/php@7.4/7.4.33/include/php -I/opt/homebrew/Cellar/php@7.4/7.4.33/include/php/main -I/opt/homebrew/Cellar/php@7.4/7.4.33/include/php/TSRM -I/opt/homebrew/Cellar/php@7.4/7.4.33/include/php/Zend -I/opt/homebrew/Cellar/php@7.4/7.4.33/include/php/ext -I/opt/homebrew/Cellar/php@7.4/7.4.33/include/php/ext/date/lib -I/opt/homebrew/Cellar/imagemagick/7.1.0-57/include/ImageMagick-7 -DHAVE_CONFIG_H -g -O2 -o imagick.la -export-dynamic -avoid-version -prefer-pic -module -rpath /Users/dan/work/ffw/projects/imagick/modules imagick_file.lo imagick_class.lo imagickdraw_class.lo imagickpixel_class.lo imagickpixeliterator_class.lo imagick_helpers.lo imagick.lo imagickkernel_class.lo shim_im6_to_im7.lo -Wl,-rpath,/opt/homebrew/Cellar/imagemagick/7.1.0-57/lib -L/opt/homebrew/Cellar/imagemagick/7.1.0-57/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 -L/opt/homebrew/Cellar/imagemagick/7.1.0-57/lib /opt/homebrew/Cellar/imagemagick/7.1.0-57/lib/libMagickWand-7.Q16HDRI.dylib -L/opt/homebrew/Cellar/little-cms2/2.14/lib -L/opt/homebrew/opt/freetype/lib -L/opt/homebrew/Cellar/glib/2.74.4/lib -L/opt/homebrew/opt/gettext/lib -L/opt/homebrew/Cellar/fontconfig/2.14.1/lib /opt/homebrew/Cellar/imagemagick/7.1.0-57/lib/libMagickCore-7.Q16HDRI.dylib -Wl,-rpath -Wl,/opt/homebrew/Cellar/imagemagick/7.1.0-57/lib
ld: warning: ld: warning: ld: warning: ld: warning: ld: warning: ignoring file .libs/imagick_file.o, building for macOS-arm64 but attempting to link with file built for unknown-x86_64ignoring file .libs/imagickdraw_class.o, building for macOS-arm64 but attempting to link with file built for unknown-x86_64
ld: warning: ignoring file .libs/imagick_class.o, building for macOS-arm64 but attempting to link with file built for unknown-x86_64ld: warning: ignoring file .libs/imagickkernel_class.o, building for macOS-arm64 but attempting to link with file built for unknown-x86_64
ignoring file .libs/imagick.o, building for macOS-arm64 but attempting to link with file built for unknown-x86_64
ignoring file .libs/imagickpixel_class.o, building for macOS-arm64 but attempting to link with file built for unknown-x86_64
ld: warning: ignoring file .libs/shim_im6_to_im7.o, building for macOS-arm64 but attempting to link with file built for unknown-x86_64
ignoring file .libs/imagickpixeliterator_class.o, building for macOS-arm64 but attempting to link with file built for unknown-x86_64
ld: warning: ignoring file .libs/imagick_helpers.o, building for macOS-arm64 but attempting to link with file built for unknown-x86_64
ld: in '/usr/local/lib/libltdl.7.dylib', building for macOS-arm64 but attempting to link with file built for macOS-x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [imagick.la] Error 1
ld: warning: ignoring file .libs/imagick_class.o, building for macOS-arm64 but attempting to link with file built for unknown-x86_64
You need to purge all previously built files.
You appear to be linking with some random file that the linker doesn't understand.
Hi,
Posting a similar error here in hope for some pointers:
ld: warning: directory not found for option '-L/opt/homebrew/Cellar/glib/2.76.3/lib'
ld: in '/usr/local/lib/libglib-2.0.0.dylib', building for macOS-arm64 but attempting to link with file built for macOS-x86_64
That's when I run pecl install imagick
(PHP 8.2 M1 chip).
I've tried removing and reinstalling ImageMagick, to no avail.
You need to purge all previously built files.
Unfortunately I don't know how to do that – any idea what the process would be with regard to the above error messages, by any chance?
In case somebody ends up here with a similar issue. So you've probably upgraded to an M1 mac from an Intel one, and you're maintaining two versions of Homebrew and their installed libraries, some of which conflicting with each other.
The way I dealt with this is by figuring out to which library the files causing building for macOS-arm64 but attempting to link with file built for macOS-x86_64
issues belong to.
So for instance for this one:
ld: in '/usr/local/lib/libglib-2.0.0.dylib', building for macOS-arm64 but attempting to link with file built for macOS-x86_64
I looked up libglib-2.0.0.dylib
and saw that it's part of the Glib library. First thing to attempt here is to reinstall it:
$ brew reinstall glib
That fixed the error in my case, but then had similar problems with other files when trying to install imagick again. Thing is, reinstalling was not always enough – I sometimes had to get rid of the x86_64 version of the library.
That's where you need to use the old brew binary to uninstall the library. Thankfully when I upgraded at the time I created an alias for it:
alias oldbrew=/usr/local/bin/brew
Check this Gist for details.
Once you've identified the location of the old binary, use it to uninstall whatever library is causing conflicts. In my case I had to do it for PCRE2, for instance:
$ oldbrew uninstall pcre2
I repeated the process until pecl install imagick
ran successfully.
I'm running into errors when trying to install on MacOS with ARM64 CPU. Is this supported?
PHP 8.0.13 imagemagick 7.1.0-16 installed with Brew
Issue occurs either when installing with
pecl install imagick
orphpize && ./configure
+make
. Installs fine when running witharch -x86_64 pecl install imagick
, however, the imagick.so module doesn't load as PHP is expecting this to be arm64 (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')).