Reputation: 684
I know this question asked before, my CPP file is :
#include <shlobj.h>
int main(int argc, char *argv[])
{
PWSTR pszPath;
HRESULT hr = SHGetKnownFolderPath(&FOLDERID_Startup,0,NULL,&pszPath);
}
And i am using Linux Mingw compiler to compile it for windows by this command :
i686-w64-mingw32-gcc hub.cpp
or
x86_64-w64-mingw32-g++ hub.cpp
And i get :
In function ‘int main(int, char**)’:
error: ‘SHGetKnownFolderPath’ was not declared in this scope
&pszPath);
^
Adding these to the header doesn't help, and i get same error:
#define WINVER 0x0600
#include <windows.h>
or
#define WINVER 0x0600
#define _WIN32_WINNT 0x0600
And I've looked into shlobj.h, and SHGetKnownFolderPath is in it.
How can i fix it ?
EDIT :
The change my friend ssbssa suggested in the comments to put #define _WIN32_WINNT 0x0600 before #include <shlobj.h>
, raise a new error and a new note :
hub.cpp: In function ‘int main(int, char**)’:
hub.cpp:8:69: error: invalid initialization of reference of type ‘const KNOWNFOLDERID& {aka const _GUID&}’ from expression of type ‘const GUID* {aka const _GUID*}’
HRESULT hr = SHGetKnownFolderPath(&FOLDERID_Startup,0,NULL,&pszPath);
^
In file included from hub.cpp:2:0:
/usr/share/mingw-w64/include/shlobj.h:755:10: note: in passing argument 1 of ‘HRESULT SHGetKnownFolderPath(const KNOWNFOLDERID&, DWORD, HANDLE, WCHAR**)’
STDAPI SHGetKnownFolderPath (REFKNOWNFOLDERID rfid, DWORD dwFlags, HANDLE hToken, PWST
I can see the error say , It expect a pointer and I gave him an adress, but i don't know how to declare it in the right way.
Upvotes: 1
Views: 865
Reputation: 7285
Try adding #define NTDDI_VERSION 0x06000000
before #include <windows.h>
Upvotes: 2