zlib building and linking issues
Recent change of zlib build system from autotools to cmake produces some issues on my system. I am using Mojave 10.14.6 with Xcode 10.3. During the build zlib issues several warnings:
MACOSX_RPATH is not specified for the following targets:
zlib
This warning is for project developers. Use -Wno-dev to suppress it.
-- Generating done
CMake Warning:
Manually-specified variables were not used by the project:
CMAKE_INSTALL_LIBDIR
Then, I have got errors when building gobject-introspection and other packages that have dependencies on zlib. Linker complains that libzlib is not found. otool gave me following:
otool -L /Users/andrius/gtk/inst/lib/libgio-2.0.0.dylib
/Users/andrius/gtk/inst/lib/libgio-2.0.0.dylib:
/Users/andrius/gtk/inst/lib/libgio-2.0.0.dylib (compatibility version 7201.0.0, current version 7201.2.0)
/Users/andrius/gtk/inst/lib/libglib-2.0.0.dylib (compatibility version 7201.0.0, current version 7201.2.0)
/Users/andrius/gtk/inst/lib/libgobject-2.0.0.dylib (compatibility version 7201.0.0, current version 7201.2.0)
/Users/andrius/gtk/inst/lib/libgmodule-2.0.0.dylib (compatibility version 7201.0.0, current version 7201.2.0)
libz.1.dylib (compatibility version 1.0.0, current version 1.2.12)
/Users/andrius/gtk/inst/lib/libintl.9.dylib (compatibility version 11.0.0, current version 11.4.0)
/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1575.17.0)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1575.17.0)
/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 1671.60.107)
/usr/lib/libresolv.9.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.250.1)
/System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 946.0.0)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
libz.1.dylib
path seems to incorrect, and thats why linker could not find it.
When errors happens, going to shell and executing
install_name_tool -change libz.1.dylib /Users/andrius/gtk/inst/lib/libz.1.dylib /Users/andrius/gtk/inst/lib/libgio-2.0.0.dylib
fixes issue. I had to do this for several other libs as well.