brew install zlib-devel on Mac OS X Mavericks

79,348

Solution 1

Just run in the command line:

xcode-select --install

In OS X 10.9+, the command line developer tools are now installed on demand. So after running this also zlib and zlib-devel should be available (no need for brew install zlib...)

Solution 2

For OS X Mojave

sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /

The reason is because Xcode Command Line tools no longer installs needed headers in /include. You have to run a separate command to install the needed headers.

As noted here - https://developer.apple.com/documentation/xcode_release_notes/xcode_10_release_notes

The command line tools will search the SDK for system headers by default. However, some software may fail to build correctly against the SDK and require macOS headers to be installed in the base system under /usr/include. If you are the maintainer of such software, we encourage you to update your project to work with the SDK or file a bug report for issues that are preventing you from doing so. As a workaround, an extra package is provided which will install the headers to the base system. In a future release, this package will no longer be provided. You can find this package at: /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg To make sure that you're using the intended version of the command line tools, run xcode-select -s or xcode select -s /Library/Developer/CommandLineTools after installing.

Solution 3

xcode-select --install doesn't solve this on Mojave for some reason.

Since this is the only library blocking, go to https://www.zlib.net and download source code. Select the "US (zlib.net)" hyperlink about halfway down the page for the tar.xz version.

Then find the download on your local machine and double click on the file. This will unzip the download and create a new folder in the same directly.

Then in Terminal:

  • cd into the directory with the download
  • then tar -xvf zlib-1.2.11.tar.xz (Note that zlib-1.2.11.tar.xz may change depending on the latest version you've downloaded. Just run whatever file you're just downloaded.)
  • Change directories cd zlib-1.2.11
  • ./configure
  • make
  • make install

Solution 4

After running

xcode-select --install

Make sure your export these variables for the compiler and the pkg-config to find zlib

For compilers to find zlib you may need to set:

export LDFLAGS="-L/usr/local/opt/zlib/lib"
export CPPFLAGS="-I/usr/local/opt/zlib/include"

For pkg-config to find zlib you may need to set:

export PKG_CONFIG_PATH="/usr/local/opt/zlib/lib/pkgconfig"

This is solved my issue with zlib

zipimport.ZipImportError: can't decompress data; zlib not available

Solution 5

In OS X 10.15 Catalina you need to run xcrun --show-sdk-path to see where it is and than provide that path to compiler or do something like

export CPATH=`xcrun --show-sdk-path`/usr/include

that point directly to directory where zlib.h is placed or just

export CPATH=`xcrun --show-sdk-path`/usr

depending on what path is expected

Share:
79,348

Related videos on Youtube

Ivan
Author by

Ivan

Updated on July 18, 2022

Comments

  • Ivan
    Ivan almost 2 years

    Attempting to install the zlib-devel on mac os x mavericks with homebrew doesn't work:

    brew install zlib-devel
    Error: No available formula for zlib-devel 
    Searching taps...
    

    This install

    brew install zlib
    

    works fine though.

  • iacopo
    iacopo over 7 years
    Worked for me also with OS X 10.12 (Sierra).
  • sureshvv
    sureshvv almost 7 years
    Didnt work for me, Got xcode-select: error: no developer tools were found, and no install could be requested (perhaps no UI is present), please install manually from 'developer.apple.com'.
  • narner
    narner almost 6 years
    Also seeing issues with this on Mac OS 10.14 Mojave
  • Giannis Katsini
    Giannis Katsini over 5 years
    Confirmed - works on mojave, using brew install zlib also did not work.
  • James Cazzetta
    James Cazzetta over 5 years
    Same here, anyone got a solution to this?
  • Valdimar
    Valdimar over 5 years
    This does not seem to work on Mojave 10.14.1 (18B75), with Xcode 10.1 (10B61). There appears to be no "macOS_SDK_headers_for_macOS_10.14.pkg" package, and xcode-select --install fails with the error "Can’t install the software because it is not currently available from the Software Update server." Let's hope this situation is only temporary.
  • Dave Stein
    Dave Stein over 5 years
    I also am having this issue. I ended up installing xcode manually (aka downloading via app store) and then selecting command line tool in the "Locations" area of preferences. I got further with some issues I had around intalling python. Then I got an error about zlib and here I am. brew install zlib goes and then zlib command not found if i try to run it.
  • gingerCodeNinja
    gingerCodeNinja over 5 years
    Confirmed. Thanks so much!
  • kevlarr
    kevlarr over 5 years
    Worked here as well - thanks for posting the actual installer instruction in addition to the docs
  • qxotk
    qxotk over 5 years
    Where would I find zlib-devel on my macOS High Sierra? Anyone know?
  • Darkaico
    Darkaico over 5 years
    Worked for me, this is the solution for mojave version, thanks!
  • Guido
    Guido almost 4 years
    python@2 is no longer available at brew
  • PatrickT
    PatrickT almost 4 years
    Nope, at least not anymore. Catalina.
  • Brad Solomon
    Brad Solomon almost 4 years
    With brew: brew --prefix zlib to show you the install path, and "$(brew --prefix zlib)/include" plus "$(brew --prefix zlib)/lib" to get the two needed paths
  • adamfc
    adamfc almost 4 years
    This was the only thing that worked for me too. Brew was what caused me all the issues in the first place!
  • Arnold Roa
    Arnold Roa about 3 years
    file does not exist for Big Sour
  • Cpt. Senkfuss
    Cpt. Senkfuss almost 3 years
    exporting the flags was what i needed on Big Sur for building python manually (needed an older version)
  • Son Nguyen
    Son Nguyen almost 3 years
    This works for me on Big Sur. brew install zlib ran successfully but nothing changes.
  • devjme
    devjme almost 3 years
    Nothing worked for me except this on Big Sur. I also did a brew install zlib that did nothing. Thank you!!
  • Qasim
    Qasim about 2 years
    Where do I set these export LDFLAGS? In the .zshrc or .bashrc files? I'm on Catalina (which comes with zsh).
  • Nicholas Jela
    Nicholas Jela almost 2 years
    xcode-select --install 2 xcode-select: error: command line tools are already installed, use "Software Update" to install updates