编译报错:x64与x86目标机器类型冲突,求64位zlib.lib
Absolutely, 64-bit versions of zlib.lib are definitely available—you're just missing the right way to get or build them. Let's break down your options to fix that "machine type conflict" error:
Grab official precompiled binaries
The zlib project provides precompiled 64-bit libraries for Windows, though they aren't always front-and-center. Look for the Windows-specific binary packages on the official zlib repository—you'll find separate archives for x86 and x64 architectures. Inside the x64 package, you'll find the 64-bitzlib.libyou need.Compile it yourself (quick and straightforward)
If you can't find precompiled binaries, building zlib for x64 is easy with MSVC:- Download the latest zlib source code from the official site.
- Open the x64 Native Tools Command Prompt for Visual Studio (make sure it's the 64-bit one, not x86).
- Navigate to the zlib source directory in the prompt.
- Run this command:
nmake -f win32/Makefile.msc AS=ml64 - Once compilation finishes, you'll find the 64-bit
zlib.lib(andzlib.dll) in the same directory.
Use a package manager (even easier)
If you're using vcpkg, installing the 64-bit zlib is as simple as running:vcpkg install zlib:x64-windows
Vcpkg will handle downloading, compiling, and linking the correct 64-bit library for your project automatically.
To recap that error: your project is set to target x64, but you're linking against an x86 version of zlib.lib—that's why the compiler throws the "module machine type conflict" message. Switching to the 64-bit library will resolve this immediately.
内容的提问来源于stack exchange,提问作者ibr

