When building libzip by homebrew (Mac OS 10.16), it complains make[2]: *** No rule to make target /usr/lib/libz.dylib', needed by `lib/libzip.5.3.dylib'. Stop.
, but I have /usr/lib/libz.dylib as a soft link, the real lib (libz.1.dylib) is missing.
So how could I fix this?
brew reinstall libzip
==> Installing php dependency: libzip
==> cmake .
==> make install
cd /tmp/libzip-20200703-7227-so8a0v/libzip-1.7.1/lib && /usr/local/homebrew/Library/Homebrew/shims/mac/super/clang -DHAVE_CONFIG_H -Dzip_EXPORTS -I/tmp/libzip-20200703-7227-so8a0v/libzip-1.7.1 -I/tmp/libzip-20200703-7227-so8a0v/libzip-1.7.1/lib -DNDEBUG -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.16.sdk -fPIC -fvisibility=hidden -o CMakeFiles/zip.dir/zip_winzip_aes.c.o -c /tmp/libzip-20200703-7227-so8a0v/libzip-1.7.1/lib/zip_winzip_aes.c
[ 85%] Building C object lib/CMakeFiles/zip.dir/zip_source_winzip_aes_decode.c.o
cd /tmp/libzip-20200703-7227-so8a0v/libzip-1.7.1/lib && /usr/local/homebrew/Library/Homebrew/shims/mac/super/clang -DHAVE_CONFIG_H -Dzip_EXPORTS -I/tmp/libzip-20200703-7227-so8a0v/libzip-1.7.1 -I/tmp/libzip-20200703-7227-so8a0v/libzip-1.7.1/lib -DNDEBUG -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.16.sdk -fPIC -fvisibility=hidden -o CMakeFiles/zip.dir/zip_source_winzip_aes_decode.c.o -c /tmp/libzip-20200703-7227-so8a0v/libzip-1.7.1/lib/zip_source_winzip_aes_decode.c
[ 87%] Building C object lib/CMakeFiles/zip.dir/zip_source_winzip_aes_encode.c.o
cd /tmp/libzip-20200703-7227-so8a0v/libzip-1.7.1/lib && /usr/local/homebrew/Library/Homebrew/shims/mac/super/clang -DHAVE_CONFIG_H -Dzip_EXPORTS -I/tmp/libzip-20200703-7227-so8a0v/libzip-1.7.1 -I/tmp/libzip-20200703-7227-so8a0v/libzip-1.7.1/lib -DNDEBUG -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.16.sdk -fPIC -fvisibility=hidden -o CMakeFiles/zip.dir/zip_source_winzip_aes_encode.c.o -c /tmp/libzip-20200703-7227-so8a0v/libzip-1.7.1/lib/zip_source_winzip_aes_encode.c
[ 87%] Building C object lib/CMakeFiles/zip.dir/zip_mkstempm.c.o
cd /tmp/libzip-20200703-7227-so8a0v/libzip-1.7.1/lib && /usr/local/homebrew/Library/Homebrew/shims/mac/super/clang -DHAVE_CONFIG_H -Dzip_EXPORTS -I/tmp/libzip-20200703-7227-so8a0v/libzip-1.7.1 -I/tmp/libzip-20200703-7227-so8a0v/libzip-1.7.1/lib -DNDEBUG -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.16.sdk -fPIC -fvisibility=hidden -o CMakeFiles/zip.dir/zip_mkstempm.c.o -c /tmp/libzip-20200703-7227-so8a0v/libzip-1.7.1/lib/zip_mkstempm.c
[ 87%] Building C object lib/CMakeFiles/zip.dir/zip_source_file_stdio_named.c.o
cd /tmp/libzip-20200703-7227-so8a0v/libzip-1.7.1/lib && /usr/local/homebrew/Library/Homebrew/shims/mac/super/clang -DHAVE_CONFIG_H -Dzip_EXPORTS -I/tmp/libzip-20200703-7227-so8a0v/libzip-1.7.1 -I/tmp/libzip-20200703-7227-so8a0v/libzip-1.7.1/lib -DNDEBUG -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.16.sdk -fPIC -fvisibility=hidden -o CMakeFiles/zip.dir/zip_source_file_stdio_named.c.o -c /tmp/libzip-20200703-7227-so8a0v/libzip-1.7.1/lib/zip_source_file_stdio_named.c
make[2]: *** No rule to make target `/usr/lib/libz.dylib', needed by `lib/libzip.5.3.dylib'. Stop.
libz.1.dylib
in my /usr/lib
~$ ls -l /usr/lib/libz.*
lrwxr-xr-x 1 root wheel 12 Jan 1 2020 /usr/lib/libz.1.1.3.dylib -> libz.1.dylib lrwxr-xr-x 1 root wheel 12 Jan 1 2020 /usr/lib/libz.1.2.11.dylib -> libz.1.dylib
lrwxr-xr-x 1 root wheel 12 Jan 1 2020 /usr/lib/libz.1.2.5.dylib -> libz.1.dylib
lrwxr-xr-x 1 root wheel 12 Jan 1 2020 /usr/lib/libz.1.2.8.dylib -> libz.1.dylib
lrwxr-xr-x 1 root wheel 12 Jan 1 2020 /usr/lib/libz.dylib -> libz.1.dylib
libz.1.dylib
is missing.
~$ sudo find / -name "libz.1.dylib"
/usr/local/homebrew/Cellar/zlib/1.2.11/lib/libz.1.dylib
/System/Volumes/Data/usr/local/homebrew/Cellar/zlib/1.2.11/lib/libz.1.dylib
...
(lib.1.dylib from CoreSimulator)
Thanks to Stefano Mtangoo's comment and answer, I fixed this by manually add cmake arguments to the fomula file.
brew install zlib bzip2
brew edit libzip.rb
change L22 from
system "cmake", ".", *std_cmake_args
to
system "cmake", ".", *std_cmake_args, "-DZLIB_LIBRARY_RELEASE=/usr/local/homebrew/opt/zlib/lib/libz.dylib","-DBZIP2_LIBRARY_RELEASE=/usr/local/homebrew/opt/bzip2/lib/libbz2.a", "(... rest of the args.."
(/usr/local/homebrew is my homebrew prefix.)
brew reinstall --verbose libzip
notes:
You can use brew reinstall --verbose libzip --interactive
to prevent the deletion of working directory and inspect the source.
Then use grep to find the broken cmake definitions and rerun *cmake ... * to test the settings.
I have tried set PATH/LD_LIBRARY_PATH, but it not works.