Tag Archives: MSYS2+ fatal error

[Solved] MSYS2+ fatal error: zlib.h: There is no such file or directory

Operating environment: windows+msys2+vscode

A brief introduction to msys2

MSYS2 (Minimal SYStem 2) is a standalone rewrite of MSYS, mainly for shell command line development environments. It is also a Windows software that builds on Cygwin (POSIX compatibility layer) and MinGW-w64 (from “MinGW-generation”) for better interoperability.

Problem Description: fatal error: zlib.h: There is no such file or directory

There is an error message when executing the makefile file.

Fatal error: zlib.h: There is no such file or directory

After carefully checking the header file library, it is clear that this header file exists. And I ruled out the possibility of incorrect environment configuration.

Therefore, I open the GUI of msys2. Try other possible solutions.

Enter at the command line

pacman -Ss zlib

The explanation of this command is to find related resources with the keyword “zlib”.

The search result is

At first, the only modules that showed up as installed were msys/zlib 1.2.12-2 (libraries) and msys/perl 5.32.1-2 (base-devel).

I found that the last one felt quite like what I needed, after all, it was installed and not used at best, so I gave it a try, just in case it worked. So I’m going to install msys/zlib-devel 1.2.12-2 (development) as well!

Solution

The command to install msys/zlib-devel 1.2.12-2 (development) is:

pacman -S zlib-devel

Successfully solved the problem!