Using the Windows 8 SDK to compile for Windows 7

后端 未结 4 905
一整个雨季
一整个雨季 2021-01-01 07:10

(This question uses zlib as an example but isn\'t specific to it.)

I\'m trying to compile zlib on Windows using the MSVC project file it comes with. I\'m using VS201

4条回答
  •  情深已故
    2021-01-01 07:42

    This question is old but if anyone still has this problem, I just succeded building latest zlib with msvc 12.0 targeting windows 7 by modifying the code in (iowin32.c file line 28) like so:

    #if _WIN32_WINNT >= _WIN32_WINNT_WIN8
    #if defined(WINAPI_FAMILY_PARTITION) && (!(defined(IOWIN32_USING_WINRT_API)))
    #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
    #define IOWIN32_USING_WINRT_API 1
    #endif
    #endif
    #endif
    

    of course to make this work you need to define a macro in: configuration properties >C/C++ > preprocessor:

    _WIN32_WINNT=0x0601
    

    which means you're targeting windows 7 (if using windows 7 SDK this is not needed)

    then rebuilding the project with success :) and yes, of course this fix is only aplicable if you're using a windows older than windows 8.

    however this is not the only error that zlib has, you will for sure encounter a mismatched version in zlib.def file. to fix this open the zlib.def file that contains the error and replace 1.2.8 with 1.28 or whatever the version is

提交回复
热议问题