iliaal / php_excel

PHP Extension interface to the Excel writing/reading library
http://ilia.ws
533 stars 131 forks source link

Having trouble compiling against php72 (ius) #248

Closed jthanto closed 3 years ago

jthanto commented 5 years ago

Hi. I'm having problems making php_excel to compile with libxl.

We have previously used php7 (ius) with libxl 3.6.5.0 successfully. But now we are upgrading to php 7.2. I have successfully upgraded php, and are about to compile php_excel. I have tried with version 3.6.5.0 which we have a license for, but I have also tried to compile 3.8.4.0 just to be sure.

What i have done so far is cloning the php_excel repo, changed branch to php7. Put it inside /etc/ext folder. I have multiple version of libxl in /usr/lib/

content of my /etc/ext/ is excel (php_excel - branch php7)

relevant content /usr/lib libxl (3.6.5, previously compiled against php70, the one i would rather use as i already have a license) libxl-3840 (3.8.4 the one i feel should work, but i need to buy license for)

cd /etc/ext/excel phpize ./configure --with-libxl-libdir=/usr/lib/libxl/lib64 --with-libxl-incdir=/usr/lib/libxl/include_c make

It errors

In file included from /usr/include/php/main/php.h:39:0, from /etc/ext/excel/excel.c:26: /etc/ext/excel/excel.c: In function 'zm_startup_excel': /etc/ext/excel/excel.c:79:40: error: 'excel_funcs_autofilter' undeclared (first use in this function) INIT_CLASS_ENTRY(ce, "Excel" # name, excelfuncs ## c_name); \ ^ /usr/include/php/Zend/zend_API.h:234:53: note: in definition of macro 'INIT_CLASS_ENTRY_INIT_METHODS' class_container.info.internal.builtin_functions = functions; \ ^ /usr/include/php/Zend/zend_API.h:238:2: note: in expansion of macro 'INIT_OVERLOADED_CLASS_ENTRY_EX' INIT_OVERLOADED_CLASS_ENTRY_EX(class_container, class_name, sizeof(class_name)-1, functions, handle_fcall, handle_propget, handle_propset, NULL, NULL) ^ /usr/include/php/Zend/zend_API.h:189:2: note: in expansion of macro 'INIT_OVERLOADED_CLASS_ENTRY' INIT_OVERLOADED_CLASS_ENTRY(class_container, class_name, functions, NULL, NULL, NULL) ^ /etc/ext/excel/excel.c:79:3: note: in expansion of macro 'INIT_CLASS_ENTRY' INIT_CLASS_ENTRY(ce, "Excel" # name, excelfuncs ## c_name); \ ^ /etc/ext/excel/excel.c:6728:2: note: in expansion of macro 'REGISTER_EXCEL_CLASS' REGISTER_EXCEL_CLASS(AutoFilter, autofilter, NULL); ^ /etc/ext/excel/excel.c:79:40: note: each undeclared identifier is reported only once for each function it appears in INIT_CLASS_ENTRY(ce, "Excel" # name, excelfuncs ## c_name); \ ^ /usr/include/php/Zend/zend_API.h:234:53: note: in definition of macro 'INIT_CLASS_ENTRY_INIT_METHODS' class_container.info.internal.builtin_functions = functions; \ ^ /usr/include/php/Zend/zend_API.h:238:2: note: in expansion of macro 'INIT_OVERLOADED_CLASS_ENTRY_EX' INIT_OVERLOADED_CLASS_ENTRY_EX(class_container, class_name, sizeof(class_name)-1, functions, handle_fcall, handle_propget, handle_propset, NULL, NULL) ^ /usr/include/php/Zend/zend_API.h:189:2: note: in expansion of macro 'INIT_OVERLOADED_CLASS_ENTRY' INIT_OVERLOADED_CLASS_ENTRY(class_container, class_name, functions, NULL, NULL, NULL) ^ /etc/ext/excel/excel.c:79:3: note: in expansion of macro 'INIT_CLASS_ENTRY' INIT_CLASS_ENTRY(ce, "Excel" # name, excelfuncs ## c_name); \ ^ /etc/ext/excel/excel.c:6728:2: note: in expansion of macro 'REGISTER_EXCEL_CLASS' REGISTER_EXCEL_CLASS(AutoFilter, autofilter, NULL); ^ /etc/ext/excel/excel.c:80:22: error: 'excel_object_new_autofilter' undeclared (first use in this function) ce.create_object = excel_objectnew ## c_name; \ ^ /etc/ext/excel/excel.c:6728:2: note: in expansion of macro 'REGISTER_EXCEL_CLASS' REGISTER_EXCEL_CLASS(AutoFilter, autofilter, NULL); ^ /etc/ext/excel/excel.c:81:3: error: 'excel_ce_autofilter' undeclared (first use in this function) excelce ## c_name = zend_register_internal_class_ex(&ce, NULL); \ ^ /etc/ext/excel/excel.c:6728:2: note: in expansion of macro 'REGISTER_EXCEL_CLASS' REGISTER_EXCEL_CLASS(AutoFilter, autofilter, NULL); ^ /etc/ext/excel/excel.c:82:11: error: 'excel_object_handlers_autofilter' undeclared (first use in this function) memcpy(&excel_objecthandlers ## c_name, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); \ ^ /etc/ext/excel/excel.c:6728:2: note: in expansion of macro 'REGISTER_EXCEL_CLASS' REGISTER_EXCEL_CLASS(AutoFilter, autofilter, NULL); ^ /etc/ext/excel/excel.c:6728:2: error: unknown type name 'excel_autofilter_object' /etc/ext/excel/excel.c:84:48: error: 'excel_autofilter_object_free_storage' undeclared (first use in this function) excel_objecthandlers ## c_name .freeobj = excel ## c_name ## _object_free_storage; \ ^ /etc/ext/excel/excel.c:6728:2: note: in expansion of macro 'REGISTER_EXCEL_CLASS' REGISTER_EXCEL_CLASS(AutoFilter, autofilter, NULL); ^ In file included from /usr/include/php/main/php.h:39:0, from /etc/ext/excel/excel.c:26: /etc/ext/excel/excel.c:79:40: error: 'excel_funcs_filtercolumn' undeclared (first use in this function) INIT_CLASS_ENTRY(ce, "Excel" # name, excelfuncs ## c_name); \ ^ /usr/include/php/Zend/zend_API.h:234:53: note: in definition of macro 'INIT_CLASS_ENTRY_INIT_METHODS' class_container.info.internal.builtin_functions = functions; \ ^ /usr/include/php/Zend/zend_API.h:238:2: note: in expansion of macro 'INIT_OVERLOADED_CLASS_ENTRY_EX' INIT_OVERLOADED_CLASS_ENTRY_EX(class_container, class_name, sizeof(class_name)-1, functions, handle_fcall, handle_propget, handle_propset, NULL, NULL) ^ /usr/include/php/Zend/zend_API.h:189:2: note: in expansion of macro 'INIT_OVERLOADED_CLASS_ENTRY' INIT_OVERLOADED_CLASS_ENTRY(class_container, class_name, functions, NULL, NULL, NULL) ^ /etc/ext/excel/excel.c:79:3: note: in expansion of macro 'INIT_CLASS_ENTRY' INIT_CLASS_ENTRY(ce, "Excel" # name, excelfuncs ## c_name); \ ^ /etc/ext/excel/excel.c:6729:2: note: in expansion of macro 'REGISTER_EXCEL_CLASS' REGISTER_EXCEL_CLASS(FilterColumn, filtercolumn, NULL); ^ /etc/ext/excel/excel.c:80:22: error: 'excel_object_new_filtercolumn' undeclared (first use in this function) ce.create_object = excel_objectnew ## c_name; \ ^ /etc/ext/excel/excel.c:6729:2: note: in expansion of macro 'REGISTER_EXCEL_CLASS' REGISTER_EXCEL_CLASS(FilterColumn, filtercolumn, NULL); ^ /etc/ext/excel/excel.c:81:3: error: 'excel_ce_filtercolumn' undeclared (first use in this function) excelce ## c_name = zend_register_internal_class_ex(&ce, NULL); \ ^ /etc/ext/excel/excel.c:6729:2: note: in expansion of macro 'REGISTER_EXCEL_CLASS' REGISTER_EXCEL_CLASS(FilterColumn, filtercolumn, NULL); ^ /etc/ext/excel/excel.c:82:11: error: 'excel_object_handlers_filtercolumn' undeclared (first use in this function) memcpy(&excel_objecthandlers ## c_name, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); \ ^ /etc/ext/excel/excel.c:6729:2: note: in expansion of macro 'REGISTER_EXCEL_CLASS' REGISTER_EXCEL_CLASS(FilterColumn, filtercolumn, NULL); ^ /etc/ext/excel/excel.c:6729:2: error: unknown type name 'excel_filtercolumn_object' /etc/ext/excel/excel.c:84:48: error: 'excel_filtercolumn_object_free_storage' undeclared (first use in this function) excel_objecthandlers ## c_name .freeobj = excel ## c_name ## _object_free_storage; \ ^ /etc/ext/excel/excel.c:6729:2: note: in expansion of macro 'REGISTER_EXCEL_CLASS' REGISTER_EXCEL_CLASS(FilterColumn, filtercolumn, NULL); ^ make: *** [excel.lo] Error 1

I don't really know what to do, I'm guessing I'm doing something wrong. I couldn't really figure out the

"# change into php source files directory cd php-7.x.x" part of the routine, as i could find a folder to run ./buildconf --force. All help is really appreciated.

johmue commented 5 years ago

To me it looks as if the C preprocessor lines carrying a ## make trouble. Can you please tell which OS you use?

Jan-E commented 5 years ago

Cannot reproduce this on CentOS 6 with PHP 7.2.14. Build log:

[root@vps2 src]# git clone -b php7_with_pulls https://github.com/Jan-E/php_excel phpexcel7_with_pulls
Initialized empty Git repository in /usr/local/src/phpexcel7_with_pulls/.git/
remote: Enumerating objects: 1184, done.
remote: Total 1184 (delta 0), reused 0 (delta 0), pack-reused 1184
Receiving objects: 100% (1184/1184), 584.21 KiB, done.
Resolving deltas: 100% (744/744), done.

[root@vps2 src]# cd phpexcel7_with_pulls

[root@vps2 phpexcel7_with_pulls]# cat ../phpize72.sh
export PATH=/usr/local/php72/bin:$PATH
phpize
bash

[root@vps2 phpexcel7_with_pulls]# ../phpize72.sh
Configuring for:
PHP Api Version:         20170718
Zend Module Api No:      20170718
Zend Extension Api No:   320170718

[root@vps2 phpexcel7_with_pulls]# cat ../php_excel.sh
export CFLAGS=-I/usr/local/include/libxml2
export CPPFLAGS=-I/usr/local/include/libxml2
./configure --with-excel=../libxl-3.8.4.0/ --with-libxl-libdir=../libxl-3.8.4.0/lib64 --with-libxl-incdir=../libxl-3.8.4.0/include_c --with-libxml-dir=/usr/local/lib

[root@vps2 phpexcel7_with_pulls]# ../php_excel.sh
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for PHP prefix... /usr/local/php72
checking for PHP includes... -I/usr/local/php72/include/php -I/usr/local/php72/include/php/main -I/usr/local/php72/include/php/TSRM -I/usr/local/php72/include/php/Zend -I/usr/local/php72/include/php/ext -I/usr/local/php72/include/php/ext/date/lib
checking for PHP extension directory... /usr/local/php72/lib/php/extensions/no-debug-non-zts-20170718
checking for PHP installed headers prefix... /usr/local/php72/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk... gawk
checking whether to enable excel support... yes, shared
checking C include dir for libxl... yes, shared
checking lib dir for libxl... yes, shared
checking libxml2 install dir... yes, shared
checking for excel includes... found in ../libxl-3.8.4.0/include_c
checking for excel libraries... found in ../libxl-3.8.4.0/lib64
checking for libxml2... not found
checking for xlCreateBookCA in -lxl... yes
checking for xlBookSetKeyA in -lxl... yes
checking for ld used by cc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for /usr/bin/ld option to reload object files... -r
checking for BSD-compatible nm... /usr/bin/nm -B
checking whether ln -s works... yes
checking how to recognize dependent libraries... pass_all
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking the maximum length of command line arguments... 1966080
checking command to parse /usr/bin/nm -B output from cc object... ok
checking for objdir... .libs
checking for ar... ar
checking for ranlib... ranlib
checking for strip... strip
checking if cc supports -fno-rtti -fno-exceptions... no
checking for cc option to produce PIC... -fPIC
checking if cc PIC flag -fPIC works... yes
checking if cc static flag -static works... no
checking if cc supports -c -o file.o... yes
checking whether the cc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no

creating libtool
appending configuration tag "CXX" to libtool
configure: creating ./config.status
config.status: creating config.h

[root@vps2 phpexcel7_with_pulls]# make
/bin/sh /usr/local/src/phpexcel7_with_pulls/libtool --mode=compile cc  -I. -I/usr/local/src/phpexcel7_with_pulls -DPHP_ATOM_INC -I/usr/local/src/phpexcel7_with_pulls/include -I/usr/local/src/phpexcel7_with_pulls/main -I/usr/local/src/phpexcel7_with_pulls -I/usr/local/php72/include/php -I/usr/local/php72/include/php/main -I/usr/local/php72/include/php/TSRM -I/usr/local/php72/include/php/Zend -I/usr/local/php72/include/php/ext -I/usr/local/php72/include/php/ext/date/lib -I/usr/local/src/libxl-3.8.4.0/include_c  -I/usr/local/include/libxml2 -DHAVE_CONFIG_H  -I/usr/local/include/libxml2   -c /usr/local/src/phpexcel7_with_pulls/excel.c -o excel.lo
mkdir .libs
 cc -I. -I/usr/local/src/phpexcel7_with_pulls -DPHP_ATOM_INC -I/usr/local/src/phpexcel7_with_pulls/include -I/usr/local/src/phpexcel7_with_pulls/main -I/usr/local/src/phpexcel7_with_pulls -I/usr/local/php72/include/php -I/usr/local/php72/include/php/main -I/usr/local/php72/include/php/TSRM -I/usr/local/php72/include/php/Zend -I/usr/local/php72/include/php/ext -I/usr/local/php72/include/php/ext/date/lib -I/usr/local/src/libxl-3.8.4.0/include_c -I/usr/local/include/libxml2 -DHAVE_CONFIG_H -I/usr/local/include/libxml2 -c /usr/local/src/phpexcel7_with_pulls/excel.c  -fPIC -DPIC -o .libs/excel.o
/usr/local/src/phpexcel7_with_pulls/excel.c: In function ‘zim_ExcelSheet_table’:
/usr/local/src/phpexcel7_with_pulls/excel.c:4745: warning: passing argument 3 of ‘xlSheetTableA’ from incompatible pointer type
/usr/local/src/libxl-3.8.4.0/include_c/SheetA.h:179: note: expected ‘int *’ but argument is of type ‘zend_long *’
/usr/local/src/phpexcel7_with_pulls/excel.c:4745: warning: passing argument 4 of ‘xlSheetTableA’ from incompatible pointer type
/usr/local/src/libxl-3.8.4.0/include_c/SheetA.h:179: note: expected ‘int *’ but argument is of type ‘zend_long *’
/usr/local/src/phpexcel7_with_pulls/excel.c:4745: warning: passing argument 5 of ‘xlSheetTableA’ from incompatible pointer type
/usr/local/src/libxl-3.8.4.0/include_c/SheetA.h:179: note: expected ‘int *’ but argument is of type ‘zend_long *’
/usr/local/src/phpexcel7_with_pulls/excel.c:4745: warning: passing argument 6 of ‘xlSheetTableA’ from incompatible pointer type
/usr/local/src/libxl-3.8.4.0/include_c/SheetA.h:179: note: expected ‘int *’ but argument is of type ‘zend_long *’
/usr/local/src/phpexcel7_with_pulls/excel.c:4745: warning: passing argument 7 of ‘xlSheetTableA’ from incompatible pointer type
/usr/local/src/libxl-3.8.4.0/include_c/SheetA.h:179: note: expected ‘int *’ but argument is of type ‘zend_long *’
/usr/local/src/phpexcel7_with_pulls/excel.c:4745: warning: passing argument 8 of ‘xlSheetTableA’ from incompatible pointer type
/usr/local/src/libxl-3.8.4.0/include_c/SheetA.h:179: note: expected ‘int *’ but argument is of type ‘zend_long *’
/usr/local/src/phpexcel7_with_pulls/excel.c: In function ‘zim_ExcelFilterColumn_getCustomFilter’:
/usr/local/src/phpexcel7_with_pulls/excel.c:5269: warning: passing argument 3 of ‘xlFilterColumnGetCustomFilterA’ from incompatible pointer type
/usr/local/src/libxl-3.8.4.0/include_c/FilterColumnA.h:23: note: expected ‘const char **’ but argument is of type ‘char **’
/usr/local/src/phpexcel7_with_pulls/excel.c:5269: warning: passing argument 5 of ‘xlFilterColumnGetCustomFilterA’ from incompatible pointer type
/usr/local/src/libxl-3.8.4.0/include_c/FilterColumnA.h:23: note: expected ‘const char **’ but argument is of type ‘char **’
/bin/sh /usr/local/src/phpexcel7_with_pulls/libtool --mode=link cc -DPHP_ATOM_INC -I/usr/local/src/phpexcel7_with_pulls/include -I/usr/local/src/phpexcel7_with_pulls/main -I/usr/local/src/phpexcel7_with_pulls -I/usr/local/php72/include/php -I/usr/local/php72/include/php/main -I/usr/local/php72/include/php/TSRM -I/usr/local/php72/include/php/Zend -I/usr/local/php72/include/php/ext -I/usr/local/php72/include/php/ext/date/lib -I/usr/local/src/libxl-3.8.4.0/include_c  -I/usr/local/include/libxml2 -DHAVE_CONFIG_H  -I/usr/local/include/libxml2   -o excel.la -export-dynamic -avoid-version -prefer-pic -module -rpath /usr/local/src/phpexcel7_with_pulls/modules  excel.lo -Wl,-rpath,/usr/local/src/libxl-3.8.4.0/lib64 -L/usr/local/src/libxl-3.8.4.0/lib64 -lxl -Wl,-rpath,/usr/local/src/libxl-3.8.4.0/lib64 -L/usr/local/src/libxl-3.8.4.0/lib64 -lxl
cc -shared  .libs/excel.o  -L/usr/local/src/libxl-3.8.4.0/lib64 -lxl  -Wl,-rpath -Wl,/usr/local/src/libxl-3.8.4.0/lib64 -Wl,-rpath -Wl,/usr/local/src/libxl-3.8.4.0/lib64 -Wl,-soname -Wl,excel.so -o .libs/excel.so
creating excel.la
(cd .libs && rm -f excel.la && ln -s ../excel.la excel.la)
/bin/sh /usr/local/src/phpexcel7_with_pulls/libtool --mode=install cp ./excel.la /usr/local/src/phpexcel7_with_pulls/modules
cp ./.libs/excel.so /usr/local/src/phpexcel7_with_pulls/modules/excel.so
cp ./.libs/excel.lai /usr/local/src/phpexcel7_with_pulls/modules/excel.la
PATH="$PATH:/sbin" ldconfig -n /usr/local/src/phpexcel7_with_pulls/modules
----------------------------------------------------------------------
Libraries have been installed in:
   /usr/local/src/phpexcel7_with_pulls/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

Build complete.
Don't forget to run 'make test'.

[root@vps2 phpexcel7_with_pulls]# make install
Installing shared extensions:     /usr/local/php72/lib/php/extensions/no-debug-non-zts-20170718/
jthanto commented 5 years ago

To me it looks as if the C preprocessor lines carrying a ## make trouble. Can you please tell which OS you use?

I'm using CentOS Linux release 7.6.1810 I actually found that it works using https://github.com/Jan-E/php_excel/tree/php7-issue234. But only for latest libxl version, not for the 3.6.5. Guessing that makes sense since i read about some API changes for some of the latest libxl releases.