1

I'm trying to install php zip module on my new Macbook M1, by using:

pecl install zip

After a while i'm getting this error:

configure: error: Please reinstall the libzip distribution
ERROR: `/private/tmp/pear/temp/zip/configure --with-php-config=/Applications/MAMP/bin/php/php7.4.15/bin/php-config' failed

So i run:

brew install libzip

And i get:

Warning: libzip 1.7.3 is already installed and up-to-date.

At this point i'm stucked. Any idea?

Thank you

  • Does this answer your question? [configure: error: Please reinstall the libzip distribution](https://stackoverflow.com/questions/45775877/configure-error-please-reinstall-the-libzip-distribution) – Haridarshan Jun 17 '21 at 13:57
  • None of them are available with brew for osx – Andrea Lunelio Jun 17 '21 at 13:59
  • First run this `xcode-select --install` and then try to install libzip developer package – Haridarshan Jun 17 '21 at 14:01
  • Even after that it's not getting installed you'll need to build it from source. Reference to install developer packages: https://stackoverflow.com/questions/23749530/brew-install-zlib-devel-on-mac-os-x-mavericks – Haridarshan Jun 17 '21 at 14:03
  • `xcode-select: error: command line tools are already installed, use "Software Update" to install updates` I tried to build libzip from source also, but after launching ./configure i still get: `checking for libzip... not found.. configure: error: Please reinstall the libzip distribution` – Andrea Lunelio Jun 17 '21 at 14:07
  • You tried building `zip` from source or `libzip`? – Haridarshan Jun 17 '21 at 14:09
  • remove libzip distribution and build libzip from source so that it will build and install developer dependencies for php zip extension – Haridarshan Jun 17 '21 at 14:10
  • Could you help me understand how to install libzip-devel for osx? I already managed to compile libzip from source – Andrea Lunelio Jun 17 '21 at 14:24
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/233899/discussion-between-andrea-lunelio-and-haridarshan). – Andrea Lunelio Jun 17 '21 at 14:29
  • Since you've managed to build to libzip, `pecl install zip` should work now – Haridarshan Jun 17 '21 at 15:25
  • Unfortunately no, same message `checking for libzip... not found configure: error: Please reinstall the libzip distribution ERROR: `/private/tmp/pear/temp/zip/configure --with-php-config=/Applications/MAMP/bin/php/php7.4.15/bin/php-config' failed` – Andrea Lunelio Jun 18 '21 at 14:42
  • What is OS X version? – Haridarshan Jun 18 '21 at 16:47
  • Also, please share the command you've used to build libzip – Haridarshan Jun 18 '21 at 16:51
  • macOs 11.4.. to build libzip: `mkdir build && cd build` `cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local/libzip` `make && make install` – Andrea Lunelio Jun 21 '21 at 07:54
  • Have you created the symbolic links as you've installed libzip in other folder https://noknow.info/it/os/install_libzip_from_source#sec4 – Haridarshan Jun 21 '21 at 07:57
  • I set symbolic links for /bin and /include. Files /lib/*.so are not present in my installation folder, i have *.dylib only files – Andrea Lunelio Jun 21 '21 at 08:15
  • Now when i run `pecl install zip` it doesn't find any available release – Andrea Lunelio Jun 21 '21 at 08:16
  • That's weird, I've build libzip from source on Fedora 33 and installed zip and worked smoothly... Only change was `cmake -DCMAKE_INSTALL_PREFIX=/usr/local ..` – Haridarshan Jun 21 '21 at 08:36
  • ok get the zip source tar and build that too – Haridarshan Jun 21 '21 at 08:36
  • what do you mean? i already built from zip source tar [https://libzip.org/download/libzip-1.8.0.tar.xz] – Andrea Lunelio Jun 21 '21 at 09:56
  • I mean download the php zip extension source tar and build that extension – Haridarshan Jun 21 '21 at 09:57
  • Downloaded v1.19.3, run `./configure` and get always `checking for libzip... not found configure: error: Please reinstall the libzip distribution` :( – Andrea Lunelio Jun 21 '21 at 10:16
  • first get `php-config` path via `which php-config`, second `phpize && ./configure --with-php-config=path of php-config --with-libzip=/usr/local/libzip`, third `make && make install` – Haridarshan Jun 21 '21 at 10:26
  • I've modified the `./configure` command add `--with-libzip` – Haridarshan Jun 21 '21 at 10:35
  • Finally it compiled, added php.so extension to php.ini but unfortunately when i try to load the library i get this error: `PHP Startup: Unable to load dynamic library 'zip.so' (tried: /Applications/MAMP/bin/php/php7.4.15/lib/php/extensions/no-debug-non-zts-20190902/zip.so (dlopen(/Applications/MAMP/bin/php/php7.4.15/lib/php/extensions/no-debug-non-zts-20190902/zip.so, 9): no suitable image found. Did find: /Applications/MAMP/bin/php/php7.4.15/lib/php/extensions/no-debug-non-zts-20190902/zip.so: mach-o, but wrong architecture` – Andrea Lunelio Jun 21 '21 at 10:57
  • `/Applications/MAMP/bin/php/php7.4.15/lib/php/extensions/no-debug-non-zts-20190902/zip.so: mach-o, but wrong architecture), /Applications/MAMP/bin/php/php7.4.15/lib/php/extensions/no-debug-non-zts-20190902/zip.so.so (dlopen(/Applications/MAMP/bin/php/php7.4.15/lib/php/extensions/no-debug-non-zts-20190902/zip.so.so, 9): image not found)) in Unknown on line 0` – Andrea Lunelio Jun 21 '21 at 10:58
  • What is the output of `file ` _e.g. `file /opt/remi/php80/root/usr/bin/php`_ – Haridarshan Jun 21 '21 at 16:15
  • If the binary is `32-bit` instead of `64-bit`, then recompile php zip extension `./configure CFLAGS="-arch i386" --with-php-config=path of php-config --with-libzip=/usr/local/libzip` – Haridarshan Jun 21 '21 at 16:19
  • Output is `Mach-O 64-bit executable x86_64` I'm on a new M1 Macbook with silicon chip – Andrea Lunelio Jun 21 '21 at 17:06
  • Can you please check the output of `file `? – Haridarshan Jun 22 '21 at 08:46
  • This is the output my friend `Mach-O 64-bit bundle arm64` – Andrea Lunelio Jun 22 '21 at 11:06
  • Ok issue is `zip` extension is build for architecture `arm64` whereas `php` is using `x86_64` architecture, so it's giving `wrong architecture` error. Before rebuilding `zip` extension check `libzip` is build for `x86_64` or `arm64` using `file` utility, if it is build for `arm64` then you'll need to rebuild libzip as well for `x86_64` and then will have to rebuild `zip` extension. Here is the configure command for php `zip` extension `./configure CFLAGS="-arch x86_64" --with-php-config=path of php-config --with-libzip=/usr/local/libzip` – Haridarshan Jun 22 '21 at 14:51
  • So i recompiled libzip with command `cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local/libzip -DCMAKE_OSX_ARCHITECTURES=x86_64` and then zip with `phpize && ./configure CFLAGS="-arch x86_64" --with-php-config=/Applications/MAMP/bin/php/php7.4.15/bin/php-config --with-libzip=/usr/local/libzip` Zip.so generated and `file .../zip.so` output is `Mach-O 64-bit bundle x86_64` Yet the library is not working, same wrong architecture error of before. Damn! – Andrea Lunelio Jun 24 '21 at 09:02
  • In /usr/local/libzip/lib i have different versions of libzip.*.dylib and they all are x86_64 except for `libzip.5.3.dylib` that is still arm64. Could this be the issue? – Andrea Lunelio Jun 24 '21 at 09:15
  • Yes that could be the issue. This should help https://stackoverflow.com/a/1439989/2324206 – Haridarshan Jun 24 '21 at 10:51

0 Answers0