jingjingxyk / swoole-cli

SWOOLE-CLI is a php binary distribution composed swoole & php-core & cli & php-fpm and mostly of common extensions.
10 stars 0 forks source link

xlswriter 编译失败 #46

Closed nekic closed 1 year ago

nekic commented 1 year ago

php 8.1.16, 添加 xlswriter 1.5.4 扩展,执行 build-make-php-8.sh,

config 如下:

#!/bin/bash

set -exu
__DIR__=$(
  cd "$(dirname "$0")"
  pwd
)

cd ${__DIR__}

export PATH=/usr/pgsql/bin/:/usr/libffi/bin/:$PATH

PKG_CONFIG_PATH=''
test -d /usr/lib/pkgconfig && PKG_CONFIG_PATH="/usr/lib/pkgconfig:$PKG_CONFIG_PATH"

export CC=clang
export CXX=clang++
export LD=ld.lld
export PKG_CONFIG_PATH=/usr/openssl/lib/pkgconfig:/usr/libxml2/lib/pkgconfig:/usr/libxslt/lib/pkgconfig:/usr/brotli/lib/pkgconfig:/usr/cares/lib/pkgconfig:/usr/gmp/lib/pkgconfig:/usr/ncurses/lib/pkgconfig:/usr/readline/lib/pkgconfig:/usr/libyaml/lib/pkgconfig:/usr/libsodium/lib/pkgconfig:/usr/bzip2/lib/pkgconfig:/usr/zlib/lib/pkgconfig:/usr/liblz4/lib/pkgconfig:/usr/liblzma/lib/pkgconfig:/usr/libzstd/lib/pkgconfig:/usr/libzip/lib/pkgconfig:/usr/sqlite3/lib/pkgconfig:/usr/icu/lib/pkgconfig:/usr/oniguruma/lib/pkgconfig:/usr/mimalloc/lib/pkgconfig:/usr/libjpeg/lib64/pkgconfig:/usr/libpng/lib/pkgconfig:/usr/libwebp/lib/pkgconfig:/usr/freetype/lib/pkgconfig:/usr/imagemagick/lib/pkgconfig:/usr/libidn2/lib/pkgconfig:/usr/curl/lib/pkgconfig:/usr/pgsql/lib/pkgconfig:/usr/libffi/lib/pkgconfig:$PKG_CONFIG_PATH

version=$(cat version.txt)

mkdir -p build
cd build

test -d php-src && rm -rf php-src
mkdir -p php-src/
tar --strip-components=1 -C php-src/ -xf ${__DIR__}/download/${version}.tar.gz

cd php-src/

install_prefix_dir="/tmp/${version}"
mkdir -p $install_prefix_dir

mkdir -p ext/redis
mkdir -p ext/mongodb
mkdir -p ext/yaml
mkdir -p ext/apcu
mkdir -p ext/imagick
mkdir -p ext/ds
mkdir -p ext/inotify
mkdir -p ext/swoole
mkdir -p ext/xlswriter

tar --strip-components=1 -C ext/redis -xf ${__DIR__}/download/redis-5.3.7.tgz
tar --strip-components=1 -C ext/mongodb -xf ${__DIR__}/download/mongodb-1.15.0.tgz
tar --strip-components=1 -C ext/yaml -xf ${__DIR__}/download/yaml-2.2.2.tgz
tar --strip-components=1 -C ext/apcu -xf ${__DIR__}/download/apcu-5.1.22.tgz
tar --strip-components=1 -C ext/imagick -xf ${__DIR__}/download/imagick-3.6.0.tgz
tar --strip-components=1 -C ext/ds -xf ${__DIR__}/download/ds-1.4.0.tgz
tar --strip-components=1 -C ext/inotify -xf ${__DIR__}/download/inotify-3.0.0.tgz

#tar --strip-components=1 -C ext/swoole -xf ${__DIR__}/swoole-5.0.1.tgz
tar --strip-components=1 -C ext/swoole -xf ${__DIR__}/download/swoole-v5.0.2.tar.gz

tar --strip-components=1 -C ext/xlswriter -xf ${__DIR__}/download/xlswriter-1.5.4.tgz

# cp -f ${__DIR__}/php-src/ext/openssl/config0.m4 ${__DIR__}/php-src/ext/openssl/config.m4

OPTIONS="--disable-all \
--enable-fpm \
--enable-shared=no \
--enable-static=yes \
--disable-cgi \
--disable-phpdbg \
--enable-opcache \
--with-curl \
--with-iconv=/usr/libiconv \
--with-bz2=/usr/bzip2 \
--enable-bcmath \
--enable-pcntl \
--enable-filter \
--enable-session \
--enable-tokenizer \
--enable-mbstring \
--enable-ctype \
--with-zlib --with-zlib-dir=/usr/zlib \
--with-zip \
--enable-posix \
--enable-sockets \
--enable-pdo \
--with-sqlite3 \
--enable-phar \
--enable-mysqlnd \
--with-mysqli \
--enable-intl \
--enable-fileinfo \
--with-pdo_mysql  \
--with-pdo-sqlite \
--enable-soap \
--with-xsl \
--with-gmp=/usr/gmp \
--enable-exif \
--with-sodium \
--with-openssl --with-openssl-dir=/usr/openssl \
--with-readline=/usr/readline \
--enable-xml --enable-simplexml --enable-xmlreader --enable-xmlwriter --enable-dom --with-libxml \
--enable-gd --with-jpeg --with-freetype --with-webp \
--enable-redis \
--enable-swoole --enable-sockets --enable-mysqlnd --enable-swoole-curl --enable-cares --with-brotli-dir=/usr/brotli \
--with-yaml=/usr/libyaml \
--with-imagick=/usr/imagemagick \
--with-pgsql=/usr/pgsql \
--with-pdo-pgsql=/usr/pgsql \
--enable-mongodb \
--enable-apcu \
--with-ffi \
--enable-ds \
--enable-inotify \
--with-xlswriter \
--with-libxlsxwriter=/usr/libxlsxwriter \
"

# --enable-mongodb
# mongodb 扩展支持 php-8.1
# 重点:
# mongodb 扩展暂时(2023-02-26)不支持 php-8.20

test -f ./configure && rm ./configure ;

./buildconf --force ;

./configure --help

export   ICU_CFLAGS=$(pkg-config --cflags --static icu-i18n  icu-io   icu-uc)
export   ICU_LIBS=$(pkg-config   --libs   --static icu-i18n  icu-io   icu-uc)
export   ONIG_CFLAGS=$(pkg-config --cflags --static oniguruma)
export   ONIG_LIBS=$(pkg-config   --libs   --static oniguruma)
export   LIBSODIUM_CFLAGS=$(pkg-config --cflags --static libsodium)
export   LIBSODIUM_LIBS=$(pkg-config   --libs   --static libsodium)
export   LIBZIP_CFLAGS=$(pkg-config --cflags --static libzip) ;
export   LIBZIP_LIBS=$(pkg-config   --libs   --static libzip) ;
export   LIBPQ_CFLAGS=$(pkg-config  --cflags --static       libpq)
export   LIBPQ_LIBS=$(pkg-config    --libs   --static       libpq)

export   XSL_CFLAGS=$(pkg-config --cflags --static libxslt) ;
export   XSL_LIBS=$(pkg-config   --libs   --static libxslt) ;

package_names="readline icu-i18n  icu-io   icu-uc libpq libffi"
package_names="${package_names} openssl libcares  libidn2  libzstd libbrotlicommon  libbrotlidec  libbrotlienc"
package_names="${package_names} "

CPPFLAGS=$(pkg-config  --cflags-only-I --static $package_names )
export   CPPFLAGS="$CPPFLAGS -I/usr/include"
LDFLAGS=$(pkg-config   --libs-only-L   --static $package_names )
export   LDFLAGS="$LDFLAGS -L/usr/lib"
LIBS=$(pkg-config      --libs-only-l   --static $package_names )
export  LIBS="$LIBS -lstdc++"

./configure  --prefix=$install_prefix_dir $OPTIONS

sed -ie 's/-export-dynamic//g' "Makefile"
sed -ie 's/-o $(SAPI_CLI_PATH)/-all-static -o $(SAPI_CLI_PATH)/g' "Makefile"

cd ${__DIR__}

编译 结果报错:

1 warning generated.
In file included from main/internal_functions_cli.c:74:
In file included from /work/build-tools/php-8/build/php-src/ext/xlswriter/php_xlswriter.h:16:
In file included from /work/build-tools/php-8/build/php-src/ext/xlswriter/include/xlswriter.h:34:
/work/build-tools/php-8/build/php-src/ext/xlswriter/include/excel.h:48:1: warning: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
VTIFUL_STARTUP_FUNCTION(excel);
^
int
/work/build-tools/php-8/build/php-src/ext/xlswriter/include/excel.h:48:25: error: a parameter list without types is only allowed in a function definition
VTIFUL_STARTUP_FUNCTION(excel);
                        ^
In file included from main/internal_functions_cli.c:74:
In file included from /work/build-tools/php-8/build/php-src/ext/xlswriter/php_xlswriter.h:16:
In file included from /work/build-tools/php-8/build/php-src/ext/xlswriter/include/xlswriter.h:35:
/work/build-tools/php-8/build/php-src/ext/xlswriter/include/validation.h:18:1: warning: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
VTIFUL_STARTUP_FUNCTION(validation);
^
int
/work/build-tools/php-8/build/php-src/ext/xlswriter/include/validation.h:18:25: error: a parameter list without types is only allowed in a function definition
VTIFUL_STARTUP_FUNCTION(validation);
                        ^
In file included from main/internal_functions_cli.c:74:
In file included from /work/build-tools/php-8/build/php-src/ext/xlswriter/php_xlswriter.h:16:
In file included from /work/build-tools/php-8/build/php-src/ext/xlswriter/include/xlswriter.h:36:
/work/build-tools/php-8/build/php-src/ext/xlswriter/include/exception.h:18:1: warning: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
VTIFUL_STARTUP_FUNCTION(exception);
^
int
/work/build-tools/php-8/build/php-src/ext/xlswriter/include/exception.h:18:25: error: a parameter list without types is only allowed in a function definition
VTIFUL_STARTUP_FUNCTION(exception);
                        ^
In file included from main/internal_functions_cli.c:74:
In file included from /work/build-tools/php-8/build/php-src/ext/xlswriter/php_xlswriter.h:16:
In file included from /work/build-tools/php-8/build/php-src/ext/xlswriter/include/xlswriter.h:37:
/work/build-tools/php-8/build/php-src/ext/xlswriter/include/format.h:18:1: warning: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
VTIFUL_STARTUP_FUNCTION(format);
^
int
/work/build-tools/php-8/build/php-src/ext/xlswriter/include/format.h:18:25: error: a parameter list without types is only allowed in a function definition
VTIFUL_STARTUP_FUNCTION(format);
                        ^
In file included from main/internal_functions_cli.c:74:
In file included from /work/build-tools/php-8/build/php-src/ext/xlswriter/php_xlswriter.h:16:
In file included from /work/build-tools/php-8/build/php-src/ext/xlswriter/include/xlswriter.h:38:
/work/build-tools/php-8/build/php-src/ext/xlswriter/include/chart.h:18:1: warning: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
VTIFUL_STARTUP_FUNCTION(chart);
^
int
/work/build-tools/php-8/build/php-src/ext/xlswriter/include/chart.h:18:25: error: a parameter list without types is only allowed in a function definition
VTIFUL_STARTUP_FUNCTION(chart);
                        ^
In file included from main/internal_functions_cli.c:74:
In file included from /work/build-tools/php-8/build/php-src/ext/xlswriter/php_xlswriter.h:16:
In file included from /work/build-tools/php-8/build/php-src/ext/xlswriter/include/xlswriter.h:39:
/work/build-tools/php-8/build/php-src/ext/xlswriter/include/rich_string.h:18:1: warning: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
VTIFUL_STARTUP_FUNCTION(rich_string);
^
int
/work/build-tools/php-8/build/php-src/ext/xlswriter/include/rich_string.h:18:25: error: a parameter list without types is only allowed in a function definition
VTIFUL_STARTUP_FUNCTION(rich_string);
                        ^
6 warnings and 6 errors generated.
make: *** [Makefile:4012: main/internal_functions_cli.lo] Error 1
make: *** Waiting for unfinished jobs....
/work/build-tools/php-8/build/php-src/main/fastcgi.c:1745:36: warning: a function declaration without a prototype is deprecated in all versions of C [-Wstrict-prototypes]
const char *fcgi_get_last_client_ip()
                                   ^
                                    void
1 warning generated.
jingjingxyk commented 1 year ago

xlswriter 扩展的依赖库libxlswriter 你安装了吗? @nekic

jingjingxyk commented 1 year ago
//扩展参数还需要调试,我有时间我调试以下
//install_libxlsxwriter($p); //依赖zlib openssl (使用cmake,便于配置参数)

https://github.com/jingjingxyk/swoole-cli/blob/a2d97378160bc36dc5246ef179091ab8afe2c45e/library_builder.php#L53

jingjingxyk commented 1 year ago

@nekic 你说的没错,我试了很多遍,确实编译通过不了 。需要修改扩展源码 ,详情查看这里: https://github.com/viest/php-ext-xlswriter/issues/393

nekic commented 1 year ago

这个问题已被处理,关闭此 issue