php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76345 fatal error: zip.h: No such file or directory
Submitted: 2018-05-15 21:57 UTC Modified: 2019-01-30 13:36 UTC
Votes:8
Avg. Score:3.8 ± 1.0
Reproduced:5 of 6 (83.3%)
Same Version:1 (20.0%)
Same OS:1 (20.0%)
From: tholforty at gmail dot com Assigned:
Status: Closed Package: Compile Failure
PHP Version: 7.2.5 OS: CentOS 7.4
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: tholforty at gmail dot com
New email:
PHP Version: OS:

 

 [2018-05-15 21:57 UTC] tholforty at gmail dot com
Description:
------------
the config.m4 make config file is missing the PHP_ADD_INCLUDE() macro. This is an issue with all versions that include --with-libzip=DIR from v5.6 to v7.2

I'm building multiple php versions on the server and do not have any intention of working with the base yum installed version. As such I didn't install the libzip-devel package that puts headers (albeit old ones) into the system include. I compiled libzip into /opt/libzip and used --with-libzip=/opt/libzip for the php compile. That is how I ran into the issue.

As a control, php compiles just fine without the libtidy-devel package installed and specifying --with-tidy=/opt/libtidy.

With the setup in ext/zip/config.m4 as is, make will look for zip.h in the system /usr/include and not in the include of the directory specified in --with-libzip=DIR. Without a system level installation of zip.h, this error occurs during make:

In file included from main/internal_functions_cli.c:36:0:
/usr/local/src/git-php72-build/php-src/ext/zip/php_zip.h:31:17: fatal error: zip.h: No such file or directory
 #include <zip.h>
                 ^
compilation terminated.
make: *** [main/internal_functions_cli.lo] Error 1



Test script:
---------------
So without a system level installation of zip.h the following will fail during make with: fatal error: zip.h: No such file or directory

./configure \
--prefix=/opt/php72 \
--enable-zip \
--with-libzip=/opt/libzip \
--with-zlib && make



Expected result:
----------------
In file included from main/internal_functions_cli.c:36:0:
/usr/local/src/git-php72-build/php-src/ext/zip/php_zip.h:31:17: fatal error: zip.h: No such file or directory
 #include <zip.h>
                 ^
compilation terminated.
make: *** [main/internal_functions_cli.lo] Error 1


Patches

libzip_config.m4_add_PHP_ADD_INCLUDE_macro (last revision 2018-05-15 22:00 UTC by tholforty at gmail dot com)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-05-16 07:08 UTC] tholforty at gmail dot com
-Package: zip +Package: Compile Failure
 [2018-05-16 07:08 UTC] tholforty at gmail dot com
Changed to compile failure, since it is not an issue with PECL:Zip
 [2018-06-14 08:00 UTC] imoco at qq dot com
me too,my php version:7.2.6 os:centos 7.5
 [2019-01-30 02:39 UTC] han at 163 dot com
Me too. What should I do?
 [2019-01-30 13:36 UTC] tholforty at gmail dot com
the patch provided should fix it. it is patching ext/zip/libzip_config.m4. 
it is simply adding PHP_ADD_INCLUDE macro in a couple places to make sure the compiler looks in the custom specified place first.
 [2019-03-18 05:05 UTC] mnikulin at plesk dot com
The issue may be worse if incompatible zip.h presents in search path,
e.g. old version installed as a system package to /usr/include.
Different alignment of structure fields might potentially lead
to crashes. Fortunately it seems that no declarations from
zip.h is used outside of ext/zip.

The patch attached earlier looks malformed.

In my opinion zip.h belongs to implementation details, so should not
be used outside of ext/zip, so php_zip.h should be split into
public and internal parts.

Minimal workaround without modification of php_zip.h is

Index: configure.ac
===================================================================
--- configure.ac.orig
+++ configure.ac
@@ -1525,8 +1525,8 @@ PHP_ADD_SOURCES(main/streams, streams.c
        plain_wrapper.c userspace.c transports.c xp_socket.c mmap.c \
        glob_wrapper.c, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
 
-PHP_ADD_SOURCES(/main, internal_functions.c, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1, sapi)
-PHP_ADD_SOURCES_X(/main, internal_functions_cli.c, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1, PHP_BINARY_OBJS)
+PHP_ADD_SOURCES(/main, internal_functions.c, [-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 $LIBZIP_CFLAGS], sapi)
+PHP_ADD_SOURCES_X(/main, internal_functions_cli.c, [-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 $LIBZIP_CFLAGS], PHP_BINARY_OBJS)
 
 PHP_ADD_SOURCES(Zend, \
     zend_language_parser.c zend_language_scanner.c \
 [2019-05-26 09:32 UTC] maroszek at gmx dot net
I can reproduce this issue. I used this minimal patch to fix the issue.

--- php-7.3.5-src/ext/zip/config.m4	2019-04-30 10:37:24.000000000 +0200
+++ php-7.3.5-patched/ext/zip/config.m4	2019-05-26 11:09:15.000000000 +0200
@@ -116,6 +116,7 @@
     ])
 
     AC_DEFINE(HAVE_ZIP,1,[ ])
+    PHP_EVAL_INCLINE($LIBZIP_CFLAGS)
     PHP_NEW_EXTENSION(zip, php_zip.c zip_stream.c, $ext_shared,, $LIBZIP_CFLAGS)
     PHP_SUBST(ZIP_SHARED_LIBADD)
   else


I added PRs for master and PHP 7.3.
https://github.com/php/php-src/pull/4190 (master)
https://github.com/php/php-src/pull/4191 (7.3)
 [2019-05-27 15:45 UTC] nikic@php.net
Automatic comment on behalf of maroszek@gmx.net
Revision: http://git.php.net/?p=php-src.git;a=commit;h=a0c9d0849aa5e53c37f8fd68db80412364e8edaf
Log: Fixed bug #76345
 [2019-05-27 15:45 UTC] nikic@php.net
-Status: Open +Status: Closed
 [2021-04-12 10:04 UTC] jasmina at jianway dot co dot uk
I'm installing via PHP PECL module installer on WHM and I'm getting this error. What can I do to install this correctly?

Starting to download zip-1.19.2.tgz (325,915 bytes)
................................done: 325,915 bytes
19 source files, building
running: phpize
Configuring for:
PHP Api Version:         20180731
Zend Module Api No:      20180731
Zend Extension Api No:   320180731

...

In file included from /root/tmp/pear/zip/php73/php_zip.h:30:0,
                 from /root/tmp/pear/zip/php73/php_zip.c:36:
/usr/local/include/zip.h:59:21: fatal error: zipconf.h: No such file or directory
 #include 
                     ^
compilation terminated.
make: *** [php73/php_zip.lo] Error 1
ERROR: `make' failed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 23:01:28 2024 UTC