Opened 5 months ago

Closed 3 months ago

#18349 closed build error (wontfix)

wxWidgets not compiling with g++ 7.3.0 and g++ 8.2.0

Reported by: N4ut1lus Owned by:
Priority: normal Milestone:
Component: build Version: 3.1.2
Keywords: build, compiler Cc: v495470@…
Blocked By: Blocking:
Patch: no

Description

Using Windows10.

I was using the Code::Blocks MinGW C/C++ compilers to compile wxWidgets 3.0.4. I believe I was using gcc-g++ 5.1.0. But I read that installing Code::Blocks without compilers, and installing the compilers through MinGW, would fix a problem of mine related to the huge list of "deprecated" warnings of wxWidgets.

So, I uninstalled Code::Blocks and the associated MinGW version. Then, I installed Code::Blocks and installed MinGW from the official website. Then, with the MinGW Installation Manager, I installed mingw32-gcc-g++-bin, version 8.2.0. However, when I tried to compile the library with the command

mingw32-make -f makefile.gcc SHARED=1 UNICODE=1 BUILD=debug

, I got the error

g++ -c -o gcc_mswuddll\coredll_msw_listctrl.o -g -O0 -mthreads  -DHAVE_W32API_H -D__WXMSW__       -D_UNICODE  -I..\..\lib\gcc_dll\mswud -I..\..\include  -W -Wall -DWXBUILDING -I..\..\src\tiff\libtiff -I..\..\src\jpeg -I..\..\src\png -I..\..\src\zlib -I..\..\src\regex -I..\..\src\expat\lib -DWXUSINGDLL -DWXMAKINGDLL_CORE -DwxUSE_BASE=0   -Wno-ctor-dtor-privacy   -MTgcc_mswuddll\coredll_msw_listctrl.o -MFgcc_mswuddll\coredll_msw_listctrl.o.d -MD -MP ../../src/msw/listctrl.cpp
../../src/msw/listctrl.cpp: In member function 'long int wxListCtrl::HitTest(const wxPoint&, int&, long int*) const':
../../src/msw/listctrl.cpp:1640:64: error: expected ')' before ';' token
         item = ListView_SubItemHitTest(GetHwnd(), &hitTestInfo);
                                                                ^
makefile.gcc:12222: recipe for target 'gcc_mswuddll\coredll_msw_listctrl.o' failed
mingw32-make: *** [gcc_mswuddll\coredll_msw_listctrl.o] Error 1

However, I have seen the code and it seemed fine (NOTE: I have corrected a header file due to this issue https://forums.wxwidgets.org/viewtopic.php?t=44446)
I then downloaded wxWidgets 3.1.2 (since someone guarantees in the comments of https://www.wxwidgets.org/news/2018/12/wxwidgets-3.1.2-released/ that it was compiling fine with gcc 8), but I got the same error.

So, I then downgraded gcc-g++ to version 7.3.0 with the command

mingw-get install "gcc<8.1.*" "gcc-g++<8.1.*"

(or something similar), but got the exact same errors.

I believe this might be also related to the compiler version (since it compiled just fine when I first compiled it with the Code::Blocks MinGW compilers), but since there was someone guaranteeing it would compile with gcc 8, I thought it would be better to let you know.

Change History (14)

comment:1 Changed 5 months ago by tomay3000

  • Cc tomay3000@… added

I suggest you install Msys2 https://www.msys2.org/
after installing Msys2, open MSYS2 MinGW 32-bit command shell and type the following command:

pacman -Syu

After it completes, Hit Ctl+C then close Msys2 from the close button and run the following comand:
pacman -Su

After it completes, run the following command:
pacman -S autoconf autogen automake automake-wrapper bash bash-completion bsdcpio bsdtar ca-certificates coreutils curl db diffutils expat file filesystem flex gawk gcc-libs gdbm gettext git glib2 gmp gnupg grep heimdal icu inetutils info less libarchive libasprintf libassuan libcrypt libcurl libedit libexpat libgc libgcrypt libgdbm libgettextpo libgpg-error libguile libintl libltdl liblzma liblzo2 libmetalink libopenssl libp11-kit libpcre libpcre16 libpcre32 libpcrecpp libpcreposix libreadline libsqlite libssh2 libtasn1 libunistring libxml2 libxslt m4 make mintty mpfr msys2-runtime ncurses openssh openssl p11-kit pacman pax-git pcre perl perl-Authen-SASL perl-Convert-BinHex perl-Encode-Locale perl-Error perl-File-Listing perl-HTML-Parser perl-HTML-Tagset perl-HTTP-Cookies perl-HTTP-Daemon perl-HTTP-Date perl-HTTP-Message perl-HTTP-Negotiate perl-IO-Socket-SSL perl-IO-stringy perl-LWP-MediaTypes perl-MIME-tools perl-MailTools perl-Net-HTTP perl-Net-SMTP-SSL perl-Net-SSLeay perl-TermReadKey perl-TimeDate perl-URI perl-WWW-RobotRules perl-libwww pkgfile sed tzcode vim wget xz zlib subversion tar --noconfirm

After it completes, I suggest you download Mingw-w64 from here: https://sourceforge.net/projects/mingw-w64/files/.

For 64bit download: https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/8.1.0/threads-win32/seh/x86_64-8.1.0-release-win32-seh-rt_v6-rev0.7z

and for 32Bit, Download: https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/8.1.0/threads-win32/sjlj/i686-8.1.0-release-win32-sjlj-rt_v6-rev0.7z

and exctract it to "C:\msys32" overriting the contents of "C:\msys32\mingw64" and "C:\msys32\mingw32".

Now you are ready to Compile wxWidgets.

Open MSYS2 MinGW 32-bit command shell and type the following:

cd /C/wxWidgets-3.1.2

mkdir build-msw-static
mkdir build-msw-shared

cd build-msw-static && PKG_CONFIG='pkg-config --static' ../configure --with-msw --disable-shared --enable-cxx11 && cd ..
cd build-msw-static && make && cd ..

cd build-msw-shared && PKG_CONFIG='pkg-config' ../configure --with-msw --enable-cxx11 && cd ..
cd build-msw-shared && make && cd ..

cd build-msw-shared && PKG_CONFIG='pkg-config' ../configure --with-msw --enable-cxx11 --enable-monolithic && cd ..
cd build-msw-shared && make && cd ..

cd build-msw-static/samples && make clean && cd ../..
cd build-msw-static/samples && make && cd ../..
cd build-msw-static/demos && make clean && cd ../..
cd build-msw-static/demos && make && cd ../..
cd build-msw-static/tests && make clean && cd ../..
cd build-msw-static/tests && make && cd ../..
cd build-msw-static/utils && make clean && cd ../..
cd build-msw-static/utils && make && cd ../..

cd samples/minimal && ../../build-msw-static/samples/minimal/minimal.exe && cd ../..
cd samples/typetest && ../../build-msw-static/samples/typetest/typetest.exe && cd ../..
cd samples/drawing && ../../build-msw-static/samples/drawing/drawing.exe && cd ../..
cd samples/splash && ../../build-msw-static/samples/splash/splash.exe && cd ../..
cd samples/widgets && ../../build-msw-static/samples/widgets/widgets.exe && cd ../..

This will build wxWidgets Static, shared and shared monolithic configurations.

Last edited 5 months ago by tomay3000 (previous) (diff)

comment:2 follow-up: Changed 5 months ago by MaartenB

That is quite excessive, the following should suffice for msys2:

Open the msys2 shell, run:

pacman -Syuu
pacman -S base-devel mingw-w64-i686-toolchain mingw-w64-x86_64-toolchain

Open the mingw32 or mingw64 shell and run your command:

mingw32-make -f makefile.gcc SHARED=1 UNICODE=1 BUILD=debug setup_h
mingw32-make -f makefile.gcc SHARED=1 UNICODE=1 BUILD=debug
Last edited 5 months ago by MaartenB (previous) (diff)

comment:3 in reply to: ↑ 2 Changed 5 months ago by tomay3000

  • Cc tomay3000@… removed

Replying to MaartenB:

That is quite excessive, the following should suffice for msys2:

Open the msys2 shell, run:

pacman -Syuu
pacman -S base-devel mingw-w64-i686-toolchain mingw-w64-x86_64-toolchain

Open the mingw32 or mingw64 shell and run your command:

mingw32-make -f makefile.gcc SHARED=1 UNICODE=1 BUILD=debug setup_h
mingw32-make -f makefile.gcc SHARED=1 UNICODE=1 BUILD=debug

I suggested SJLJ or SEH and Win32 over the default DWARF and POSIX, Because they are the most compatible for Window platform.

With my experience with Msys2, DWARF and POSIX is not the way to go, they have caused me a lot of troubles, Firebird2 for example.

And concerning the other msys2 libraries using pacman, I just thought he might need them in the future.

Last edited 5 months ago by tomay3000 (previous) (diff)

comment:4 Changed 5 months ago by MaartenB

Ok.

But I wonder why the build with MinGW fails, AppVeyor uses it without issues. https://github.com/wxWidgets/wxWidgets/blob/master/build/tools/appveyor.bat#L20

Did you perform a clean build (remove /build/msw/gcc_mswuddll directory)?

comment:5 Changed 5 months ago by vadz

  • Status changed from new to infoneeded_new

I can't explain the original error neither. There doesn't seem to be anything wrong with ListView_SubItemHitTest() definition in MinGW headers and this compiler works just fine for me, although I use configure and not the makefiles -- but I don't see what difference can it make for this particular problem.

OP, could you please look at the preprocessor output, i.e. manually run the command

g++ -E -o gcc_mswuddll\coredll_msw_listctrl.ii -g -O0 -mthreads  -DHAVE_W32API_H -D__WXMSW__       -D_UNICODE  -I..\..\lib\gcc_dll\mswud -I..\..\include  -W -Wall -DWXBUILDING -I..\..\src\tiff\libtiff -I..\..\src\jpeg -I..\..\src\png -I..\..\src\zlib -I..\..\src\regex -I..\..\src\expat\lib -DWXUSINGDLL -DWXMAKINGDLL_CORE -DwxUSE_BASE=0   -Wno-ctor-dtor-privacy   -MTgcc_mswuddll\coredll_msw_listctrl.o -MFgcc_mswuddll\coredll_msw_listctrl.o.d -MD -MP ../../src/msw/listctrl.cpp

(replacing -c with -E in the command shown above and changing the output to use the .ii extension), search for wxListCtrl::EditLabel() in the (huge) generated file and check what was the ListView_EditLabel macro expanded to in your case?

comment:6 Changed 3 months ago by Mister_L

  • Cc v495470@… added
  • Status changed from infoneeded_new to new

I can confirm the error message of the OP using MSYS and configure

with the following settings with a new install of mingw and a clean copy of wxwidgets source ($WXWIN is the path to wxWidgets main folder):

$WXWIN/configure             \
    --prefix=/mingw          \
    --enable-debug           \
    --disable-shared         \
    CXXFLAGS="-std=gnu++11"

make

As requested, I ran

g++ -E -o corelib_msw_listctrl.ii -D__WXMSW__      -DWXBUILDING -I../build_debug/src/tiff/libtiff -I../src/tiff/libtiff -I../src/jpeg -I../src/png -I../src/zlib -I../src/regex -I../src/expat/expat/lib -DwxUSE_BASE=0 -Wall -Wundef -Wunused-parameter -Wno-ctor-dtor-privacy -Woverloaded-virtual -D_LARGEFILE_SOURCE=unknown -I../build_debug/lib/wx/include/msw-unicode-static-3.1 -I../include -mthreads -g -O0 -std=gnu++11  ../src/msw/listctrl.cpp

What I found in listctrl.cpp#L1640:

    WXHWND hWnd = (WXHWND) ListView_EditLabel(GetHwnd(), item);

expands to corelib_msw_listctrl.ii (L:104193ff)

WXHWND hWnd = (WXHWND)
# 1640 "../src/msw/listctrl.cpp" 3
                          (HWND)(::SendMessageW ((
# 1640 "../src/msw/listctrl.cpp"
                          ((HWND)GetHWND())
# 1640 "../src/msw/listctrl.cpp" 3
                          ), (0x1000 + 118), (
# 1640 "../src/msw/listctrl.cpp"
                          item
# 1640 "../src/msw/listctrl.cpp" 3
                          ), 0))
# 1640 "../src/msw/listctrl.cpp"
                                                             ;

No mismatched braces here. But if you look at listctrl.cpp#L1778

        item = ListView_SubItemHitTest(GetHwnd(), &hitTestInfo);

gets expanded to corelib_msw_listctrl.ii (L:104499ff)

    {
        item =
# 1778 "../src/msw/listctrl.cpp" 3
              (INT)(::SendMessageW ((
# 1778 "../src/msw/listctrl.cpp"
              ((HWND)GetHWND())
# 1778 "../src/msw/listctrl.cpp" 3
              ), (0x1000 + 57), 0, (LPARAM)((LPLVHITTESTINFO)(
# 1778 "../src/msw/listctrl.cpp"
              &hitTestInfo
# 1778 "../src/msw/listctrl.cpp" 3
              )) )
# 1778 "../src/msw/listctrl.cpp"
                                                              ;
        *ptrSubItem = hitTestInfo.iSubItem;
    }

One opening brace in this block is not matched - even though braces were matched in the corresponding block in listctrl.cpp#1778.

The substitution for 'ListView_SubItemHitTest' or the substitution for the cast of '&hitTestInfo' seems to introduce the error.

Last edited 3 months ago by Mister_L (previous) (diff)

comment:7 follow-up: Changed 3 months ago by pb101

  • Cc pbfordev@… added

Thanks for looking into this, Mister_L.

But to me, this seems like a bug within ListView_SubItemHitTest macro definition inside a header file bundled with that specific version of MinGW (I have no issue with v8.1.0), not a wxWidgets issue.

Am I wrong?

comment:8 in reply to: ↑ 7 Changed 3 months ago by Mister_L

  • Cc v495470@… removed

Just to be sure I tried inserting the missing brace into corelib_msw_listctrl.ii manually right before the semicolon at the end of the block

WXHWND hWnd = (WXHWND)
# 1640 "../src/msw/listctrl.cpp" 3
                           (HWND)(::SendMessageW ((
# 1640 "../src/msw/listctrl.cpp"
                          ((HWND)GetHWND())
# 1640 "../src/msw/listctrl.cpp" 3
                          ), (0x1000 + 118), (
# 1640 "../src/msw/listctrl.cpp"
                          item
# 1640 "../src/msw/listctrl.cpp" 3
                          ), 0))
# 1640 "../src/msw/listctrl.cpp"
                                                             );

and compiling the updated file via

g++ -c -o corelib_msw_listctrl.o  -D__WXMSW__      -DWXBUILDING -I../build_debug/src/tiff/libtiff -I../src/tiff/libtiff -I../src/jpeg -I../src/png -I../src/zlib -I../src/regex -I../src/expat/expat/lib -DwxUSE_BASE=0 -Wall -Wundef -Wunused-parameter -Wno-ctor-dtor-privacy -Woverloaded-virtual -D_LARGEFILE_SOURCE=unknown -I../build_debug/lib/wx/include/msw-unicode-static-3.1 -I../include -mthreads -g -O0 -std=gnu++11  corelib_msw_listctrl.ii

No errors - I guess you are right and I'll test v8.1.0.

Last edited 3 months ago by Mister_L (previous) (diff)

comment:9 Changed 3 months ago by pb101

  • Cc pbfordev@… removed

Just for the reference, assuming this is actually the header used by that MinGW release:
https://osdn.net/projects/mingw/scm/git/mingw-org-wsl/blobs/5.2-trunk/w32api/include/commctrl.h, there should be one more right parenthesis at the end of line 4740 to enclose parameters of SNDMSG (SNDMSG is define for ::SendMessage).

BTW, by testing with 8.1.0, I meant mingw-w64 8.1.0. Sorry for confusion, I do not really use MinGW so I am somewhat confused at how those different distributions are related (and what they share, if anything).

comment:11 Changed 3 months ago by vadz

I don't see the problem in MinGW-w64 8.3 headers, so it's already fixed and the question is just whether it's worth switching to sending LVM_SUBITEMHITTEST directly only to work around the bug in 8.2.

Any thoughts?

comment:12 Changed 3 months ago by MaartenB

I believe MinGW-w64 uses a different source https://sourceforge.net/p/mingw-w64/mingw-w64/ci/master/tree/ thus is not affected.

mingw-org-wsl from the above references seems to get new releases every few months, so in my opinion a work around is not needed.

comment:13 Changed 3 months ago by Mister_L

  • Cc v495470@… added

That was indeed the header used in my release. With the new version of commctrl.h wxWidgets was built without errors. Yay!

Last edited 3 months ago by Mister_L (previous) (diff)

comment:14 Changed 3 months ago by vadz

  • Resolution set to wontfix
  • Status changed from new to closed

Thanks for confirming that the problem is now fixed for you. I'm closing this for now, although we might want to apply the fix if more people run into this problem.

Note: See TracTickets for help on using tickets.