(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
You can do this is you have at least the Update 1 installed for VS2012 because this gives you the ability to compile for XP, which links against a cut down version of the Windows 7 SDK.
We do this with some of our code and it is compatible across XP, Windows 7 and Windows 8.
See the MSDN blog here for details.
Crucial information below
As far as I know, the only way is to use LoadLibrary()
and GetProcAddress()
-- you can also see this in MFC Sources which handle messages native to WIn7 (or later)
e.g.: CWnd::OnGesture()
in %VCINSTALLDIR%atlmfc\src\mfc\wincore.cpp
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
You can use _WIN32_WINNT
to select which OS version you want to target. It's the zlib check which is broken. WINAPI_FAMILY_DESKTOP_APP
includes WINAPI_FAMILY_APP
so their check always succeeds. You can fix it like:
#if defined(WINAPI_FAMILY_PARTITION) && (!(defined(IOWIN32_USING_WINRT_API)))
#if WINAPI_FAMILY_ONE_PARTITION(WINAPI_FAMILY_DESKTOP_APP, WINAPI_PARTITION_APP)
#define IOWIN32_USING_WINRT_API 1
#endif
#endif
See here for more info: http://social.msdn.microsoft.com/Forums/en-US/winappswithnativecode/thread/3965645c-978c-4148-b32c-1853f7fd22b3