在 Mac OS 10.16 (Big Sur) 中通过 homebrew 构建 libzip 时找不到 libz.dylib

问题描述 投票:0回答:1

通过自制程序(Mac OS 10.16)构建libzip时,它会抱怨

make[2]: *** No rule to make target /usr/lib/libz.dylib', needed by `lib/libzip.5.3.dylib'.  Stop.
,但我有/usr/lib/libz.dylib作为软链接,真正的lib(libz.1.dylib)丢失了。

那么我该如何解决这个问题?

  1. 来自
    brew reinstall libzip
  2. 的输出

==> 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.

  1. 我的 /usr/lib 中只有到
    libz.1.dylib 
    的软链接

~$ 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

  1. libz.1.dylib
    不见了。

~$ 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)

macos cmake dynamic-linking libz
1个回答
1
投票

感谢 Stefano Mtangoo's 评论和 answer,我通过手动将 cmake 参数添加到 fomula 文件来修复此问题。

  1. 从 homebrew 安装 libzip 的依赖项。
brew install zlib bzip2
  1. 将自制库添加到 CMake 定义中。

brew edit libzip.rb

将 L22 更改为

    system "cmake", ".", *std_cmake_args

    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是我的自制程序前缀。)

  1. 重新安装 libzip。
brew reinstall --verbose libzip

备注:

您可以使用

brew reinstall --verbose libzip --interactive
来防止删除工作目录并检查源代码。

然后使用 grep 查找损坏的 cmake 定义并重新运行 *cmake ... * 来测试设置。

我尝试过设置PATH/LD_LIBRARY_PATH,但它不起作用。

© www.soinside.com 2019 - 2024. All rights reserved.