views:

29

answers:

2

I'm trying to compile some code from a Windows API. It says that certain .lib and .h files must be included in the version of the Windows 7 SDK I am using. Visual Studio shows the .h files, but gives linker errors (L2019) when I try to build the project.

How can I check what version of the Win7 SDK I have, and how can I see if it includes the necessary .lib files?

A: 

Possible solution: Go to "C:\Program Files\Microsoft SDKs\Windows" and see if there is a version installed (or if that path exists at all).

Rosarch
A: 

Did you actually tell the linker that it should link the corresponding .lib file? The project templates only link the most popular .lib files, kernel32.lib, user32.lib etc. If you use an "unusual" API function then you must also tell the linker to link the import library.

Project + Properties, Linker, Input, Additional Dependencies. If you don't know what .lib is needed then look in the SDK documentation for the API function. The .lib file is listed at the bottom of the article.

Another thing you can do is use a #pragma in your source code to tell the linker to link with a .lib. For example:

#include <shlwapi.h>
#pragma comment(lib, "shlwapi.lib")    // NOTE: need to link this .lib to get shell functions
Hans Passant
PS: *always* post your error messages in a question. You'd get a direct answer.
Hans Passant