Carlos
Carlos

Reputation: 161

How can I use the C++ shlwapi library in Visual Studio?

My program uses the PathFileExistsW function from shlwapi.h:

#include <shlwapi.h>

int main() {
    LPCWSTR folderName = L"";
    PathFileExistsW(folderName);
}

If I compile it, I get the following linker error. How to solve it.?

Example.obj : error LNK2019: unresolved external symbol __imp_PathFileExistsW
    referenced in function main

Upvotes: 5

Views: 15707

Answers (3)

Carlos
Carlos

Reputation: 161

Adding a comment lib pragma anywhere in the .cpp solves the linker error:

#pragma comment(lib, "Shlwapi.lib")

Upvotes: 4

Jiminion
Jiminion

Reputation: 5168

Add shlwapi.lib to your dependency list:

Configuration Properties -> Linker -> Input -> Additional Dependencies

Upvotes: 11

Ivan Rubinson
Ivan Rubinson

Reputation: 3339

First you need to add VC++ directories Then you need to set linker input.

Upvotes: 0

Related Questions