Project Information
- Repository: https://github.com/steemit/steem
- Project Name: Steem
This bug is reported and fixed by me and now merged.
Expected behavior
Building on MacOS should work
Actual behavior
Building on MacOS doesn't work.
How to reproduce
- Just follow https://github.com/steemit/steem/blob/c4a6da660744dd1200ce35cc0d74b24ceaff9298/doc/building.md (previous version before fix) in Building on macOS X section
Very interestingly, you'll get Could NOT find zlib (missing: ZLIB_LIBRARIES)
error, as in Recording Of The Bug section:
- Steem version: 0.20.8
- Operating system: MacOS 10.14 (Mojave) and 10.13 (High Sierra) (I've tested two versions, but may not limited to these two).
Recording Of The Bug
-- Found ZLIB: /usr/lib/libz.dylib (found version "1.2.11")
-- zlib found
-- Found BZip2: /usr/local/lib/libbz2.a (found version "1.0.6")
-- Looking for BZ2_bzCompressInit
-- Looking for BZ2_bzCompressInit - found
-- bzip2 found
-- LOG_LONG_API: ON
--
-- LOGGING LONG API CALLS
-- MAX MS: 1000
-- WARN MS: 750
--
-- Finished fc module configuration...
-- Found snappy: /usr/local/lib/libsnappy.a
CMake Error at /usr/local/Cellar/cmake/3.13.2/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find zlib (missing: ZLIB_LIBRARIES)
Call Stack (most recent call first):
/usr/local/Cellar/cmake/3.13.2/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
libraries/vendor/rocksdb/cmake/modules/Findzlib.cmake:17 (find_package_handle_standard_args)
libraries/vendor/rocksdb/CMakeLists.txt:74 (find_package)
Cause and Fix
It was a headache to me, since it previously said Found ZLIB: /usr/lib/libz.dylib (found version "1.2.11")
and zlib found
as you can see!
Finally, I found what was the problem. Most MacOS version has dynamic library of zlib by default, as you can see from /usr/lib/libz.dylib
(you can't even write in /usr/lib unless disabling SIP, which is not recommended), but no static library. But the build script keeps trying to find static library, libz.a
in the same directory, even if you give export ZLIB_LIBRARIES=$(brew --prefix)/Cellar/zlib/1.2.11/lib/
correctly!
The minimal change needed is use ZLIB_ROOT_DIR
instead of ZLIB_LIBRARIES
. Then, Findlz4.cmake
finds zlibz.a
correctly using this HINTS
. This way, you can avoid modifying the build script itself (assuming the export variable setting isn't included in there).
Likewise, it's much better to use ROOT_DIR
instead of LIBRARIES
and INCLUDE_DIR
separately for other libraries. So I've changed them for snappy too.
GitHub Account
https://github.com/economicstudio
ps. @vandeberg Thank you for merging!