cpr icon indicating copy to clipboard operation
cpr copied to clipboard

zlib installation on Windows will result in build fail

Open Necktschnagge opened this issue 3 years ago • 3 comments

Description

When zlib has been installed on Windows the installed zlib is found by cmake when creating a project:

PS B:\ARCHIVE\Repos\cpr> cmake -S . -B ./build/
[...]
-- Found ZLIB: B:/ARCHIVE/PROGRAM/GnuWin32/lib/zlib.lib (found version "1.2.3") 
[...]

and after that building fails with

B:\ARCHIVE\PROGRAM\GnuWin32\include\zconf.h(289,12): fatal error C1083: Datei (Include) kann nicht geöffnet werden: "unistd.h": No such file or directory (Quelldatei wird kompiliert B:\ARCHIVE\Repos\cpr\build\_deps\curl-src\lib\content_encoding.c) [B:\ARCHIVE\Repos\cpr\build\_deps\curl-build\lib\libcurl.vcxproj]

However, if you remove the installed GnuWin32 zlib, creating project and building works fine again.

Expected Behavior

When some zlib installation on Windows (with possibly unsupported version) is found, cpr ignores it and builds its own submodules. OR When some zlib installation on Windows is found, cpr checks if it is compatible and only uses it, if so.

Actual Behavior

cpr finds a zlib installation somewhere, relies on it while building and consecutively assumes that there is some unistd.h on Windows resulting in build fail.

Possible Fix

Just ignore if there is any zlib installation anywhere on Windows, just build your own when resolving dependencies. This might increase disk usage but is the most stable solution as far as I guess.

Steps to Reproduce

  1. Install zlib from sourceforge on Windows
  2. clone cpr repository
  3. PS cmake -B ./build/
  4. PS cmake --build ./build/

Context

I am planning to use TDLib (Telegram) in the same project with cpr. TDLib requires to install zlib on Windows using an installer like the one from sourceforge. So I installed it and later, on the next clean build, the bug appears.

Your Environment

  • Version used: master branch (2022-06-03)
  • Where did you get it from (e.g. conan, vcpkg, master, ...): github.com
  • Operating System and version: Windows 10 Home 21H2
  • Link to a small example:

Necktschnagge avatar Jun 03 '22 19:06 Necktschnagge

Oh, sorry overlooked that one. I can have a look at it next week. I also think I know why this is happening. This is probably connected to the warnings zlibng is throwing during configuration.

COM8 avatar Jun 08 '22 11:06 COM8