Reputation: 4184
I am using the SHGetSpecialFolderPath
function of the WINAPI, and also using the windows VisualExpressC++ compiler (cl.exe) to compile it. But when in linking stage I get this error:
error LNK2019: unresolved external symbol __imp___SHGetSpecialFolderPathA@16 referenced in function _main
I guess that I need to link Shell32.lib
, is this correct and how would I do it in a way that I can actually get my program running on another system, maybe even a XP instead of a 7, without recompiling it?
Upvotes: 5
Views: 15429
Reputation: 2609
Yes you will have to link to Shell32.lib. Your program will be compatible to both Windows XP and Windows 7 if you do so (as long as you don't use functions that are only available on Windows 7 or Windows Vista).
You will have to change your command line of cl.exe to:
cl program.cpp shell32.lib
Upvotes: 3
Reputation: 490338
If you're compiling from the command line, just add shell32.lib
to the command, something like this:
cl file1.cpp file2.cpp shell32.lib
You're just using a function that Windows provides. Since this particular function goes back almost to the dawn of time (Windows 95, if I recall correctly), you shouldn't have to do anything special to use it on anything reasonably current.
Upvotes: 10