Error while compiling wxWidgets-2.8.12 on MinGW wi

2020-06-27 08:21发布

问题:

I've been trying to compile wxWidgets with MinGW's GCC (version 4.8.1), and have been receiving errors from g++, saying:

../../src/msw/treectrl.cpp: In member function 'virtual bool wxTreeCtrl::MSWOnNo
tify(int, WXLPARAM, WXLPARAM*)':
../../src/msw/treectrl.cpp:2581:17: error: 'NMTVDISPINFOWW' was not declared in
this scope
                 TV_DISPINFO *info = (TV_DISPINFO *)lParam;
                 ^
../../src/msw/treectrl.cpp:2581:30: error: 'info' was not declared in this scope

                 TV_DISPINFO *info = (TV_DISPINFO *)lParam;
                              ^
../../src/msw/treectrl.cpp:2581:51: error: expected primary-expression before ')
' token
                 TV_DISPINFO *info = (TV_DISPINFO *)lParam;
                                               ^
../../src/msw/treectrl.cpp:2581:52: error: expected ';' before 'lParam'
                 TV_DISPINFO *info = (TV_DISPINFO *)lParam;
                                                ^
In file included from ..\..\include/wx/msw/gccpriv.h:22:0,
                 from ..\..\include/wx/platform.h:577,
                 from ..\..\include/wx/defs.h:21,
                 from ..\..\include/wx/wxprec.h:13,
                 from ../../src/msw/treectrl.cpp:21:
../../src/msw/treectrl.cpp:2615:17: error: 'NMTVDISPINFOWW' was not declared in
this scope
                 TV_DISPINFO *info = (TV_DISPINFO *)lParam;
                 ^
../../src/msw/treectrl.cpp:2615:30: error: 'info' was not declared in this scope

                 TV_DISPINFO *info = (TV_DISPINFO *)lParam;
                              ^
../../src/msw/treectrl.cpp:2615:51: error: expected primary-expression before ')
' token
                 TV_DISPINFO *info = (TV_DISPINFO *)lParam;
                                               ^
../../src/msw/treectrl.cpp:2615:52: error: expected ';' before 'lParam'
                 TV_DISPINFO *info = (TV_DISPINFO *)lParam;
                                                ^
In file included from ..\..\include/wx/msw/gccpriv.h:22:0,
                 from ..\..\include/wx/platform.h:577,
                 from ..\..\include/wx/defs.h:21,
                 from ..\..\include/wx/wxprec.h:13,
                 from ../../src/msw/treectrl.cpp:21:
../../src/msw/treectrl.cpp:2659:17: error: 'NMTVDISPINFOWW' was not declared in
this scope
                 TV_DISPINFO *info = (TV_DISPINFO *)lParam;
                 ^
../../src/msw/treectrl.cpp:2659:30: error: 'info' was not declared in this scope

                 TV_DISPINFO *info = (TV_DISPINFO *)lParam;
                              ^
../../src/msw/treectrl.cpp:2659:51: error: expected primary-expression before ')
' token
                 TV_DISPINFO *info = (TV_DISPINFO *)lParam;
                                                   ^
../../src/msw/treectrl.cpp:2659:52: error: expected ';' before 'lParam'
                 TV_DISPINFO *info = (TV_DISPINFO *)lParam;
                                                    ^
In file included from ..\..\include/wx/msw/gccpriv.h:22:0,
                 from ..\..\include/wx/platform.h:577,
                 from ..\..\include/wx/defs.h:21,
                 from ..\..\include/wx/wxprec.h:13,
                 from ../../src/msw/treectrl.cpp:21:
../../src/msw/treectrl.cpp:3084:17: error: 'NMTVDISPINFOWW' was not declared in
this scope
                 TV_DISPINFO *info = (TV_DISPINFO *)lParam;
                 ^
../../src/msw/treectrl.cpp:3084:30: error: 'info' was not declared in this scope

                 TV_DISPINFO *info = (TV_DISPINFO *)lParam;
                                  ^
../../src/msw/treectrl.cpp:3084:51: error: expected primary-expression before ')
' token
                 TV_DISPINFO *info = (TV_DISPINFO *)lParam;
                                                   ^
../../src/msw/treectrl.cpp:3084:52: error: expected ';' before 'lParam'
                 TV_DISPINFO *info = (TV_DISPINFO *)lParam;
                                                    ^
makefile.gcc:9310: recipe for target 'gcc_mswudll\coredll_treectrl.o' failed
mingw32-make: *** [gcc_mswudll\coredll_treectrl.o] Error 1

Can anyone help, I've tried googling, but with minimal results (and yes I did read them!).

回答1:

You seem to have a bug in your headers, NMTVDISPINFOWW (with 2 trailing Ws) doesn't exist and shouldn't appear anywhere. You can try fixing the typo in the headers themselves or downloading a distribution of gcc for Windows known to work (such as MinGW-w64 or TDM-GCC).



回答2:

A similar issue is documented here: http://mingw.5.n7.nabble.com/win32api-version-4-td32288.html
Anyway i would strongly advise to use a sjlj verion of MinGW-w64 or TDM-GCC.
The "Standard" MinGW Distribution uses dw2 exception handling which causes some issues when exceptions are passed through the eventloop.