简体   繁体   中英

Incorrect SDK/OS version?

I'm using Windows 7, Visual Studio 2012 and DirectX 11. Today I've added "DDSTextureLoader" module from DirectXTex to my project (I've just copied DDSTextureLoader.cpp and DDSTextureLoader.h into my project folder and added them into the solution). The project compiled fine but when I ran it it showed me the following error:

Entry point in method CreateFile2 can't be found in library DLL KERNEL32.dll

(Or sth like that, I have a polish version of Windows so I'm not sure about the english counterpart of this error message.)

I've found out that it has something to do with SDK version and that it can be "fixed" by changing #define _WIN32_WINNT 's value to _WIN32_WINNT_WIN7 (default is _WIN32_WINNT_WIN8 ) in the C:\\Program Files (x86)\\Windows Kits\\8.0\\Include\\shared\\sdkddkver.h .

After doing that the project seems to work fine but I don't think that manual editing of an SDK's file, especially since it's also used by all other projects , is a good solution. Is there any better way to get rid of the above-mentioned error message? Or maybe I have some error in my project/SDK setup?

The _WIN32_WINNT control define has been in use by the Windows SDK for many long years, but there was a behavior change in the Windows 8.x SDK that caused a lot of confusion: it defaults to the 'latest' OS rather than the 'oldest' OS supported.

This means that when you build a fresh project using VS 2013, it will default to 0x0603 and require Windows 8.1 or later. If you build the same desktop project using VS 2012, it defaults to 0x602 and requires Windows 8.0 or later. This makes perfect sense for Windows Store apps, but it's really confusing for Win32 desktops. Thankfully, the fix is very simple: Add the Preprocessor Definition _WIN32_WINNT=0x0600 for Win32 desktop apps built using VS 2012/VS 2013. The Windows 8.x SDK oldest supported OS is Windows Vista (0x0600). If you can count on Windows 7 or later, set it to 0x0601.

If you are using the "v110_xp" or "v120_xp" platform toolset, you are actually using the Windows 7.1A SDK which can support Windows XP and there you'd set _WIN32_WINNT=0x0501.

See MSDN

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM