pecl install imagick 在使用 PHP 8.0 的 M1 MacBook 上失败

问题描述

更新

这个问题似乎与 PECL 本身有关:

https://github.com/Imagick/imagick/issues/331


我无法运行 pecl install imagick 的构建过程,也无法从错误日志中获取任何信息。我使用装有最新 Apple M1 处理器的 Mac (OS 11.2.1)。该库与 PHP 8.0.2 结合使用

在开始构建过程之前,我安装了以下 brew 包:

所需的库

brew install pkg-config
brew install imagemagick

构建命令

pecl install imagick

构建过程日志

creating libtool
appending configuration tag "CXX" to libtool
configure: patching config.h.in
configure: creating ./config.status
config.status: creating config.h
running: make
/bin/sh /private/tmp/pear/temp/pear-build-rootgEqg8P/imagick-3.4.4/libtool --mode=compile cc -I. -I/private/tmp/pear/temp/imagick -I/private/tmp/pear/temp/pear-build-rootgEqg8P/imagick-3.4.4/include -I/private/tmp/pear/temp/pear-build-rootgEqg8P/imagick-3.4.4/main -I/private/tmp/pear/temp/imagick -I/Opt/homebrew/Cellar/PHP/8.0.2/include/PHP -I/Opt/homebrew/Cellar/PHP/8.0.2/include/PHP/main -I/Opt/homebrew/Cellar/PHP/8.0.2/include/PHP/TSRM -I/Opt/homebrew/Cellar/PHP/8.0.2/include/PHP/Zend -I/Opt/homebrew/Cellar/PHP/8.0.2/include/PHP/ext -I/Opt/homebrew/Cellar/PHP/8.0.2/include/PHP/ext/date/lib -I/Opt/homebrew/Cellar/imagemagick/7.0.11-0/include/ImageMagick-7  -DHAVE_CONfig_H  -g -O2   -Xpreprocessor -fopenmp -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16 -Xpreprocessor -fopenmp -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16 -I/Opt/homebrew/Cellar/imagemagick/7.0.11-0/include/ImageMagick-7 -c /private/tmp/pear/temp/imagick/imagick_file.c -o imagick_file.lo
mkdir .libs
 cc -I. -I/private/tmp/pear/temp/imagick -I/private/tmp/pear/temp/pear-build-rootgEqg8P/imagick-3.4.4/include -I/private/tmp/pear/temp/pear-build-rootgEqg8P/imagick-3.4.4/main -I/private/tmp/pear/temp/imagick -I/Opt/homebrew/Cellar/PHP/8.0.2/include/PHP -I/Opt/homebrew/Cellar/PHP/8.0.2/include/PHP/main -I/Opt/homebrew/Cellar/PHP/8.0.2/include/PHP/TSRM -I/Opt/homebrew/Cellar/PHP/8.0.2/include/PHP/Zend -I/Opt/homebrew/Cellar/PHP/8.0.2/include/PHP/ext -I/Opt/homebrew/Cellar/PHP/8.0.2/include/PHP/ext/date/lib -I/Opt/homebrew/Cellar/imagemagick/7.0.11-0/include/ImageMagick-7 -DHAVE_CONfig_H -g -O2 -Xpreprocessor -fopenmp -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16 -Xpreprocessor -fopenmp -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16 -I/Opt/homebrew/Cellar/imagemagick/7.0.11-0/include/ImageMagick-7 -c /private/tmp/pear/temp/imagick/imagick_file.c  -fno-common -DPIC -o .libs/imagick_file.o
In file included from /private/tmp/pear/temp/imagick/imagick_file.c:22:
/private/tmp/pear/temp/imagick/PHP_imagick_file.h:61:108: error: expected ')'
zend_bool PHP_imagick_file_init(struct PHP_imagick_file_t *file,const char *filename,size_t filename_len TSrmlS_DC);
                                                                                                           ^
/private/tmp/pear/temp/imagick/PHP_imagick_file.h:61:32: note: to match this '('
zend_bool PHP_imagick_file_init(struct PHP_imagick_file_t *file,size_t filename_len TSrmlS_DC);
                               ^
/private/tmp/pear/temp/imagick/PHP_imagick_file.h:65:54: error: expected ')'
int PHP_imagick_safe_mode_check(const char *filename TSrmlS_DC);
                                                     ^
/private/tmp/pear/temp/imagick/PHP_imagick_file.h:65:32: note: to match this '('
int PHP_imagick_safe_mode_check(const char *filename TSrmlS_DC);
                               ^
/private/tmp/pear/temp/imagick/PHP_imagick_file.h:68:134: error: expected ')'
PHP_imagick_rw_result_t PHP_imagick_read_file(PHP_imagick_object *intern,struct PHP_imagick_file_t *file,ImagickOperationType type TSrmlS_DC);
                                                                                                                                     ^
/private/tmp/pear/temp/imagick/PHP_imagick_file.h:68:46: note: to match this '('
PHP_imagick_rw_result_t PHP_imagick_read_file(PHP_imagick_object *intern,ImagickOperationType type TSrmlS_DC);
                                             ^
/private/tmp/pear/temp/imagick/PHP_imagick_file.h:71:153: error: expected ')'
PHP_imagick_rw_result_t PHP_imagick_write_file(PHP_imagick_object *intern,ImagickOperationType type,zend_bool adjoin TSrmlS_DC);
                                                                                                                                                        ^
/private/tmp/pear/temp/imagick/PHP_imagick_file.h:71:47: note: to match this '('
PHP_imagick_rw_result_t PHP_imagick_write_file(PHP_imagick_object *intern,zend_bool adjoin TSrmlS_DC);
                                              ^
/private/tmp/pear/temp/imagick/PHP_imagick_file.h:74:112: error: expected ')'
zend_bool PHP_imagick_stream_handler(PHP_imagick_object *intern,PHP_stream *stream,ImagickOperationType type TSrmlS_DC);
                                                                                                               ^
/private/tmp/pear/temp/imagick/PHP_imagick_file.h:74:37: note: to match this '('
zend_bool PHP_imagick_stream_handler(PHP_imagick_object *intern,ImagickOperationType type TSrmlS_DC);
                                    ^
/private/tmp/pear/temp/imagick/imagick_file.c:81:51: error: expected ')'
zend_bool PHP_imagick_is_url(const char *filename TSrmlS_DC)
                                                  ^
/private/tmp/pear/temp/imagick/imagick_file.c:81:29: note: to match this '('
zend_bool PHP_imagick_is_url(const char *filename TSrmlS_DC)
                            ^
/private/tmp/pear/temp/imagick/imagick_file.c:85:90: error: expected ')'
        if (PHP_stream_locate_url_wrapper(filename,&path_for_open,STREAM_LOCATE_WRAPPERS_ONLY TSrmlS_CC)) {
                                                                                                ^
/private/tmp/pear/temp/imagick/imagick_file.c:85:35: note: to match this '('
        if (PHP_stream_locate_url_wrapper(filename,STREAM_LOCATE_WRAPPERS_ONLY TSrmlS_CC)) {
                                         ^
/private/tmp/pear/temp/imagick/imagick_file.c:91:108: error: expected ')'
zend_bool PHP_imagick_file_init(struct PHP_imagick_file_t *file,size_t filename_len TSrmlS_DC)
                                                                                                           ^
/private/tmp/pear/temp/imagick/imagick_file.c:91:32: note: to match this '('
zend_bool PHP_imagick_file_init(struct PHP_imagick_file_t *file,size_t filename_len TSrmlS_DC)
                               ^
/private/tmp/pear/temp/imagick/imagick_file.c:123:40: error: expected ')'
                else if (PHP_imagick_is_url(filename TSrmlS_CC)) {
                                                     ^
/private/tmp/pear/temp/imagick/imagick_file.c:123:30: note: to match this '('
                else if (PHP_imagick_is_url(filename TSrmlS_CC)) {
                                           ^
/private/tmp/pear/temp/imagick/imagick_file.c:142:53: error: expected ')'
        file->absolute_path = expand_filepath(buffer,NULL TSrmlS_CC);
                                                           ^
/private/tmp/pear/temp/imagick/imagick_file.c:142:39: note: to match this '('
        file->absolute_path = expand_filepath(buffer,NULL TSrmlS_CC);
                                             ^
/private/tmp/pear/temp/imagick/imagick_file.c:160:133: error: expected ')'
int PHP_imagick_read_image_using_imagemagick(PHP_imagick_object *intern,ImagickOperationType type TSrmlS_DC)
                                                                                                                                    ^
/private/tmp/pear/temp/imagick/imagick_file.c:160:45: note: to match this '('
int PHP_imagick_read_image_using_imagemagick(PHP_imagick_object *intern,ImagickOperationType type TSrmlS_DC)
                                            ^
/private/tmp/pear/temp/imagick/imagick_file.c:201:133: error: expected ')'
int PHP_imagick_read_image_using_PHP_streams(PHP_imagick_object *intern,ImagickOperationType type TSrmlS_DC)
                                                                                                                                    ^
/private/tmp/pear/temp/imagick/imagick_file.c:201:45: note: to match this '('
int PHP_imagick_read_image_using_PHP_streams(PHP_imagick_object *intern,ImagickOperationType type TSrmlS_DC)
                                            ^
/private/tmp/pear/temp/imagick/imagick_file.c:207:2: error: expected ')'
        IMAGICK_SET_ERROR_HANDLING_THROW;
        ^
/private/tmp/pear/temp/imagick/imagick_file.c:28:133: note: expanded from macro 'IMAGICK_SET_ERROR_HANDLING_THROW'
#  define IMAGICK_SET_ERROR_HANDLING_THROW zend_replace_error_handling(EH_THROW,PHP_imagick_exception_class_entry,&error_handling TSrmlS_CC)
                                                                                                                                    ^
/private/tmp/pear/temp/imagick/imagick_file.c:207:2: note: to match this '('
/private/tmp/pear/temp/imagick/imagick_file.c:28:71: note: expanded from macro 'IMAGICK_SET_ERROR_HANDLING_THROW'
#  define IMAGICK_SET_ERROR_HANDLING_THROW zend_replace_error_handling(EH_THROW,&error_handling TSrmlS_CC)
                                                                      ^
/private/tmp/pear/temp/imagick/imagick_file.c:216:3: error: expected ')'
                IMAGICK_RESTORE_ERROR_HANDLING;
                ^
/private/tmp/pear/temp/imagick/imagick_file.c:29:88: note: expanded from macro 'IMAGICK_RESTORE_ERROR_HANDLING'
#  define IMAGICK_RESTORE_ERROR_HANDLING   zend_restore_error_handling(&error_handling TSrmlS_CC)
                                                                                       ^
/private/tmp/pear/temp/imagick/imagick_file.c:216:3: note: to match this '('
/private/tmp/pear/temp/imagick/imagick_file.c:29:71: note: expanded from macro 'IMAGICK_RESTORE_ERROR_HANDLING'
#  define IMAGICK_RESTORE_ERROR_HANDLING   zend_restore_error_handling(&error_handling TSrmlS_CC)
                                                                      ^
/private/tmp/pear/temp/imagick/imagick_file.c:224:3: error: expected ')'
                IMAGICK_RESTORE_ERROR_HANDLING;
                ^
/private/tmp/pear/temp/imagick/imagick_file.c:29:88: note: expanded from macro 'IMAGICK_RESTORE_ERROR_HANDLING'
#  define IMAGICK_RESTORE_ERROR_HANDLING   zend_restore_error_handling(&error_handling TSrmlS_CC)
                                                                                       ^
/private/tmp/pear/temp/imagick/imagick_file.c:224:3: note: to match this '('
/private/tmp/pear/temp/imagick/imagick_file.c:29:71: note: expanded from macro 'IMAGICK_RESTORE_ERROR_HANDLING'
#  define IMAGICK_RESTORE_ERROR_HANDLING   zend_restore_error_handling(&error_handling TSrmlS_CC)
                                                                      ^
/private/tmp/pear/temp/imagick/imagick_file.c:228:2: error: expected ')'
        IMAGICK_RESTORE_ERROR_HANDLING;
        ^
/private/tmp/pear/temp/imagick/imagick_file.c:29:88: note: expanded from macro 'IMAGICK_RESTORE_ERROR_HANDLING'
#  define IMAGICK_RESTORE_ERROR_HANDLING   zend_restore_error_handling(&error_handling TSrmlS_CC)
                                                                                       ^
/private/tmp/pear/temp/imagick/imagick_file.c:228:2: note: to match this '('
/private/tmp/pear/temp/imagick/imagick_file.c:29:71: note: expanded from macro 'IMAGICK_RESTORE_ERROR_HANDLING'
#  define IMAGICK_RESTORE_ERROR_HANDLING   zend_restore_error_handling(&error_handling TSrmlS_CC)
                                                                      ^
/private/tmp/pear/temp/imagick/imagick_file.c:255:54: error: expected ')'
int PHP_imagick_safe_mode_check(const char *filename TSrmlS_DC)
                                                     ^
/private/tmp/pear/temp/imagick/imagick_file.c:255:32: note: to match this '('
int PHP_imagick_safe_mode_check(const char *filename TSrmlS_DC)
                               ^
/private/tmp/pear/temp/imagick/imagick_file.c:262:64: error: expected ')'
        if (PG(open_basedir) && PHP_check_open_basedir_ex(filename,0 TSrmlS_CC)) {
                                                                      ^
/private/tmp/pear/temp/imagick/imagick_file.c:262:51: note: to match this '('
        if (PG(open_basedir) && PHP_check_open_basedir_ex(filename,0 TSrmlS_CC)) {
                                                         ^
/private/tmp/pear/temp/imagick/imagick_file.c:269:134: error: expected ')'
PHP_imagick_rw_result_t PHP_imagick_read_file(PHP_imagick_object *intern,ImagickOperationType type TSrmlS_DC)
                                                                                                                                     ^
/private/tmp/pear/temp/imagick/imagick_file.c:269:46: note: to match this '('
PHP_imagick_rw_result_t PHP_imagick_read_file(PHP_imagick_object *intern,ImagickOperationType type TSrmlS_DC)
                                             ^
Fatal error: too many errors emitted,stopping Now [-ferror-limit=]
20 errors generated.
make: *** [imagick_file.lo] Error 1
ERROR: `make' Failed

解决方法

你需要从 git 安装 imagick

$ git clone https://github.com/Imagick/imagick

$ cd imagick

$ phpize && ./configure

$ make

$ make test

$ make install

安装后编辑您的 php.ini 并添加行 extension="imagick.so"

重新启动 apache 并使用 phpinfo() 创建一个 index.php 以检查模块 imagick 是否正常。

$ echo "<?php phpinfo();" > /your-web-patch/index.php
,

目前还没有用于 PHP 8 的 imagick 版本。他们说大师作品,但这可能会也可能不会帮助你。请注意,这与 Apple Silicon 无关 - 它不适用于 Intel,也不适用。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...