samhocevar / portable-file-dialogs

💬 Portable GUI dialogs library, C++11, single-header

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failed to compile in windows 10 with the mingwx64 compiler

baderouaich opened this issue · comments

commented

Hello Sam,
Thank you for this cool library! its really useful.
i had an issue compiling in Windows 10 using Mingw x64, compilers version that i tried are 9.3.0, 10.1.0 and 10.2.0, all failed with error: invalid use of incomplete type 'IFileDialog' {aka 'struct IFileDialog'}
although it works perfectly with the msvc v142 compiler and other platforms like linux...
looks like the issue is with the windows version of mingw from http://winlibs.com/
i found similar issue occured with the Qt5 here may be useful

full error info

"==== Building pfd (debug) ===="
portable-file-dialogs.cpp
In file included from src/portable-file-dialogs.cpp:1:
include/portable-file-dialogs.h: In member function 'std::string pfd::internal::file_dialog::select_folder_vista(IFileDialog*, bool)':
include/portable-file-dialogs.h:1241:16: error: invalid use of incomplete type 'IFileDialog' {aka 'struct IFileDialog'}
 1241 |             ifd->SetFolder(folder);
      |                ^~
In file included from d:\mingw\10.2.0\mingw64\x86_64-w64-mingw32\include\shlobj.h:124,
                 from include/portable-file-dialogs.h:23,
                 from src/portable-file-dialogs.cpp:1:
d:\mingw\10.2.0\mingw64\x86_64-w64-mingw32\include\shobjidl.h:1063:19: note: forward declaration of 'IFileDialog' {aka
struct IFileDialog'}
 1063 | typedef interface IFileDialog IFileDialog;
      |                   ^~~~~~~~~~~
In file included from src/portable-file-dialogs.cpp:1:
include/portable-file-dialogs.h:1243:16: error: invalid use of incomplete type 'IFileDialog' {aka 'struct IFileDialog'}
 1243 |             ifd->SetDefaultFolder(folder);
      |                ^~
In file included from d:\mingw\10.2.0\mingw64\x86_64-w64-mingw32\include\shlobj.h:124,
                 from include/portable-file-dialogs.h:23,
                 from src/portable-file-dialogs.cpp:1:
d:\mingw\10.2.0\mingw64\x86_64-w64-mingw32\include\shobjidl.h:1063:19: note: forward declaration of 'IFileDialog' {aka
struct IFileDialog'}
 1063 | typedef interface IFileDialog IFileDialog;
      |                   ^~~~~~~~~~~
In file included from src/portable-file-dialogs.cpp:1:
include/portable-file-dialogs.h:1248:8: error: invalid use of incomplete type 'IFileDialog' {aka 'struct IFileDialog'}
 1248 |     ifd->SetOptions(FOS_PICKFOLDERS);
      |        ^~
In file included from d:\mingw\10.2.0\mingw64\x86_64-w64-mingw32\include\shlobj.h:124,
                 from include/portable-file-dialogs.h:23,
                 from src/portable-file-dialogs.cpp:1:
d:\mingw\10.2.0\mingw64\x86_64-w64-mingw32\include\shobjidl.h:1063:19: note: forward declaration of 'IFileDialog' {aka
struct IFileDialog'}
 1063 | typedef interface IFileDialog IFileDialog;
      |                   ^~~~~~~~~~~
In file included from src/portable-file-dialogs.cpp:1:
include/portable-file-dialogs.h:1248:21: error: 'FOS_PICKFOLDERS' was not declared in this scope
 1248 |     ifd->SetOptions(FOS_PICKFOLDERS);
      |                     ^~~~~~~~~~~~~~~
include/portable-file-dialogs.h:1249:8: error: invalid use of incomplete type 'IFileDialog' {aka 'struct IFileDialog'}
 1249 |     ifd->SetTitle(m_wtitle.c_str());
      |        ^~
In file included from d:\mingw\10.2.0\mingw64\x86_64-w64-mingw32\include\shlobj.h:124,
                 from include/portable-file-dialogs.h:23,
                 from src/portable-file-dialogs.cpp:1:
d:\mingw\10.2.0\mingw64\x86_64-w64-mingw32\include\shobjidl.h:1063:19: note: forward declaration of 'IFileDialog' {aka
struct IFileDialog'}
 1063 | typedef interface IFileDialog IFileDialog;
      |                   ^~~~~~~~~~~
In file included from src/portable-file-dialogs.cpp:1:
include/portable-file-dialogs.h:1251:13: error: invalid use of incomplete type 'IFileDialog' {aka 'struct IFileDialog'}
 1251 |     hr = ifd->Show(GetActiveWindow());
      |             ^~
In file included from d:\mingw\10.2.0\mingw64\x86_64-w64-mingw32\include\shlobj.h:124,
                 from include/portable-file-dialogs.h:23,
                 from src/portable-file-dialogs.cpp:1:
d:\mingw\10.2.0\mingw64\x86_64-w64-mingw32\include\shobjidl.h:1063:19: note: forward declaration of 'IFileDialog' {aka
struct IFileDialog'}
 1063 | typedef interface IFileDialog IFileDialog;
      |                   ^~~~~~~~~~~
In file included from src/portable-file-dialogs.cpp:1:
include/portable-file-dialogs.h:1255:17: error: invalid use of incomplete type 'IFileDialog' {aka 'struct IFileDialog'}
 1255 |         hr = ifd->GetResult(&item);
      |                 ^~
In file included from d:\mingw\10.2.0\mingw64\x86_64-w64-mingw32\include\shlobj.h:124,
                 from include/portable-file-dialogs.h:23,
                 from src/portable-file-dialogs.cpp:1:
d:\mingw\10.2.0\mingw64\x86_64-w64-mingw32\include\shobjidl.h:1063:19: note: forward declaration of 'IFileDialog' {aka
struct IFileDialog'}
 1063 | typedef interface IFileDialog IFileDialog;
      |                   ^~~~~~~~~~~
In file included from src/portable-file-dialogs.cpp:1:
include/portable-file-dialogs.h:1271:8: error: invalid use of incomplete type 'IFileDialog' {aka 'struct IFileDialog'}
 1271 |     ifd->Release();
      |        ^~
In file included from d:\mingw\10.2.0\mingw64\x86_64-w64-mingw32\include\shlobj.h:124,
                 from include/portable-file-dialogs.h:23,
                 from src/portable-file-dialogs.cpp:1:
d:\mingw\10.2.0\mingw64\x86_64-w64-mingw32\include\shobjidl.h:1063:19: note: forward declaration of 'IFileDialog' {aka
struct IFileDialog'}
 1063 | typedef interface IFileDialog IFileDialog;
      |                   ^~~~~~~~~~~
In file included from d:\mingw\10.2.0\mingw64\x86_64-w64-mingw32\include\objbase.h:14,
                 from d:\mingw\10.2.0\mingw64\x86_64-w64-mingw32\include\ole2.h:17,
                 from d:\mingw\10.2.0\mingw64\x86_64-w64-mingw32\include\wtypesbase.h:13,
                 from d:\mingw\10.2.0\mingw64\x86_64-w64-mingw32\include\shlobj.h:9,
                 from include/portable-file-dialogs.h:23,
                 from src/portable-file-dialogs.cpp:1:
d:\mingw\10.2.0\mingw64\x86_64-w64-mingw32\include\combaseapi.h: In instantiation of 'void** IID_PPV_ARGS_Helper(T**) [with T = IFileDialog]':
include/portable-file-dialogs.h:929:88:   required from here
d:\mingw\10.2.0\mingw64\x86_64-w64-mingw32\include\combaseapi.h:79:5: error: invalid 'static_cast' from type 'IFileDialog*' to type 'IUnknown*'
   79 |     static_cast<IUnknown *> (*pp);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from d:\mingw\10.2.0\mingw64\x86_64-w64-mingw32\include\shlobj.h:124,
                 from include/portable-file-dialogs.h:23,
                 from src/portable-file-dialogs.cpp:1:
d:\mingw\10.2.0\mingw64\x86_64-w64-mingw32\include\shobjidl.h:1063:19: note: class type 'IFileDialog' is incomplete
 1063 | typedef interface IFileDialog IFileDialog;
      |                   ^~~~~~~~~~~
make[1]: *** [Bin-Intermediate/Debug-windows-x86_64/pfd/portable-file-dialogs.o] Error 1
make: *** [pfd] Error 2

I'm also failing to compile on mingw32-w64:
c++.exe (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 8.1.0

Same errors, plus one macro (?) error:

frontend\debug/../pfd.h:1284:21: error: 'FOS_PICKFOLDERS' was not declared in this scope
     ifd->SetOptions(FOS_PICKFOLDERS);

All of these seem to be coming from ShlObj.h and ShObjIdl.h. Microsoft back at it again with its broken libraries!

I encountered the same issue and as a workaround I just commented those lines; therefore, the windows sdk bloatware is not needed 😄 It probably uses an older Win32 API, but looks just fine for me. Here's the header I used (it is based on a slightly older version of the header). The extension is txt due to github restrictions.

portable-file-dialogs.h.txt

Thanks for the feedback. I have disabled the use of IFileDialog for old versions of mingw64. Note that more recent versions (e.g. 10.3.0) have correct headers and compile fine.