[steem][0.20.8] Building on MacOS doesn't work - Could NOT find zlib (missing: ZLIB_LIBRARIES)

in utopian-io •  2 months ago

Project Information

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

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!

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Thanks for your contribution @blockchainstudio

As always it's great to see you both report and resolve the issues you find, great work, keep it up.

You did a great job explaining the problem and how you fixed it, I do believe that you could have included the exact steps you took within your post instead of referencing the link (this could change and become irrelevant to your post), however that has no impacted my scoring, maybe something to consider in the future :)

Although this issue may not affect all users (not using Mac) I do believe that this issue would cause a significant impact (as mentioned by yourself) on those who do and you can see that reflected in my scoring.

Once again, thanks for your contribution and look forward to your contributions in the future.


Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Chat with us on Discord.

[utopian-moderator]

·

Hi @tobias-g, thank you for review and advice! I'll do what you suggest next time. Thanks!

·

Thank you for your review, @tobias-g! Keep up the good work!

Summary in Korean: 스팀 소스 코드가 macos native build가 안됩니다. 이거 원인 찾는데 꽤 애먹었는데. 영어로 적어놓은대로 앞에선 zlib을 찾았다고 두번이나 말해놓곤 다시 그걸 못찾아서 에러가 나니까요. 그런데 macos에 기본으로 zlib shared libary만 제공되는데 먼저 그걸 찾아버리니 static library도 무조건 거기서 다시 찾으려고 해서 생기는 문제이더군요. 수정한 것이 현재 스팀 깃허브 마스터에 반영되었습니다^^

·

이런 오류도 찾아내시다니, 대단하십니다. 스팀 직원보다 더 열심히 일하시는 것 같네요. 스팀잇이랑 비지에서 월급 받으셔야 할 듯…. ㅋㅋ

·
·

ㅎㅎ이건 이전의 다른 코어 버그 수정을 하기 위해 빌드를 해봐야하니 그과정에서 우연히 찾게 되었어요. 사실 docker vm쓰면되지만 native가 속도도 빠르고 에러 메세지가 너무 신기해서 궁금해서 들여다보고 해결을 했네요. 예전에 unix관리자를 한적이 있어서 직접 컴파일해서 이것저것 설치해본 적이 많았던게 문제원인을 추측하는데 도움이 된 것 같네요^^

짱짱맨 호출에 응답하여 보팅하였습니다.

Nice one

Hi @blockchainstudio!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server

Hey, @blockchainstudio!

Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!