Ticket UUID: | 59518a2d7a97a44692fd6f5639f7e2a8a31be4a3 | |||
Title: | Compile error (undeclared identifier) in tkWinWm.c | |||
Type: | Bug | Version: | 9.0b2 | |
Submitter: | erikleunissen | Created on: | 2024-07-20 07:54:42 | |
Subsystem: | 85. Win Build | Assigned To: | jan.nijtmans | |
Priority: | 5 Medium | Severity: | Important | |
Status: | Closed | Last Modified: | 2025-04-24 11:25:01 | |
Resolution: | Duplicate | Closed By: | erikleunissen | |
Closed on: | 2025-04-24 11:25:01 | |||
Description: |
I use to build TclTk for a x86_64-mingw32 target from a linux host, using a gcc cross compiler. This went well for Tcl. For Tk, the build aborted with: /opt/toolchains/x86_64-w64-mingw32/bin/x86_64-w64-mingw32-gcc -std=gnu11 -c -O2 -fomit-frame-pointer -D_ATL_XP_TARGETING=1 -D__USE_MINGW_ANSI_STDIO=0 -Wall -Wextra -Wshadow -Wundef -Wwrite-strings -Wpointer-arith -Wc++-compat -fextended-identifiers -I"/usr/local/src/SOURCES/tk9.0b2/generic" -I"/usr/local/src/SOURCES/tk9.0b2/win" -I"../../../SOURCES/tk9.0b2/win/../xlib" -I"../../../SOURCES/tk9.0b2/win/../bitmaps" -I"/usr/local/src/SOURCES/tcl9.0b2/generic" -I"/usr/local/src/SOURCES/tcl9.0b2/win" -pipe -DHAVE_CPUID=1 -finput-charset=UTF-8 -DPACKAGE_NAME=\"tk\" -DPACKAGE_TARNAME=\"tk\" -DPACKAGE_VERSION=\"9.0\" -DPACKAGE_STRING=\"tk\ 9.0\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DHAVE_STDIO_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_STRINGS_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_UNISTD_H=1 -DSTDC_HEADERS=1 -DMODULE_SCOPE=extern -DTCL_CFG_DO64BIT=1 -DHAVE_NO_SEH=1 -DHAVE_STDBOOL_H=1 -DHAVE_CAST_TO_UNION=1 -DHAVE_INTPTR_T=1 -DHAVE_UINTPTR_T=1 -DHAVE_INTPTR_T=1 -DHAVE_UINTPTR_T=1 -DNDEBUG=1 -DTCL_CFG_OPTIMIZED=1 -DZIPFS_BUILD=1 -DTCL_UTF_MAX=4 -DUSE_TCL_STUBS -DBUILD_tk -DBUILD_ttk "/usr/local/src/SOURCES/tk9.0b2/win/tkWinWm.c" -o tkWinWm.o In file included from ../../../SOURCES/tk9.0b2/win/../xlib/X11/Xlib.h:44:0, from /usr/local/src/SOURCES/tk9.0b2/win/tkWinPort.h:70, from /usr/local/src/SOURCES/tk9.0b2/generic/tkPort.h:18, from /usr/local/src/SOURCES/tk9.0b2/generic/tkInt.h:19, from /usr/local/src/SOURCES/tk9.0b2/win/tkWinInt.h:18, from /usr/local/src/SOURCES/tk9.0b2/win/tkWinWm.c:16: /opt/toolchains/mingw-w64-20131228/x86_64-w64-mingw32/include/psdk_inc/intrin-impl.h: In function ‘_BitScanForward64’: ../../../SOURCES/tk9.0b2/win/../xlib/X11/X.h:74:23: warning: shadowed declaration is here [-Wshadow] typedef unsigned long Mask; ^ /opt/toolchains/mingw-w64-20131228/x86_64-w64-mingw32/include/psdk_inc/intrin-impl.h: In function ‘_BitScanReverse64’: ../../../SOURCES/tk9.0b2/win/../xlib/X11/X.h:74:23: warning: shadowed declaration is here [-Wshadow] /opt/toolchains/mingw-w64-20131228/x86_64-w64-mingw32/include/psdk_inc/intrin-impl.h: In function ‘_BitScanForward’: ../../../SOURCES/tk9.0b2/win/../xlib/X11/X.h:74:23: warning: shadowed declaration is here [-Wshadow] /opt/toolchains/mingw-w64-20131228/x86_64-w64-mingw32/include/psdk_inc/intrin-impl.h: In function ‘_BitScanReverse’: ../../../SOURCES/tk9.0b2/win/../xlib/X11/X.h:74:23: warning: shadowed declaration is here [-Wshadow] /usr/local/src/SOURCES/tk9.0b2/win/tkWinWm.c: In function ‘UpdateWrapper’: /usr/local/src/SOURCES/tk9.0b2/win/tkWinWm.c:2201:5: warning: implicit declaration of function ‘ChangeWindowMessageFilter’ [-Wimplicit-function-declaration] ChangeWindowMessageFilter(TaskbarButtonCreatedMessageId, MSGFLT_ADD); ^ /usr/local/src/SOURCES/tk9.0b2/win/tkWinWm.c:2201:62: error: ‘MSGFLT_ADD’ undeclared (first use in this function) ChangeWindowMessageFilter(TaskbarButtonCreatedMessageId, MSGFLT_ADD); ^ /usr/local/src/SOURCES/tk9.0b2/win/tkWinWm.c:2201:62: note: each undeclared identifier is reported only once for each function it appears in make: *** [/usr/local/src/BUILD/x86_64-mingw32/tk9.0b2/Makefile:812: tkWinWm.o] Error 1 | |||
User Comments: |
erikleunissen added on 2025-04-24 11:25:01:
And closing as a duplicate of [f6d40f9902].
erikleunissen added on 2025-04-24 11:08:21: Re-opening with additional analysis and patch.
Please see ticket [f6d40f9902].
jan.nijtmans added on 2024-08-28 07:41:39: > ... and wouldn't mind closing this ticket now as not reproducible Done. Feel free to re-open whenever you have more information or a new suggestion which could make your environment work. erikleunissen added on 2024-08-26 09:40:45: Thanks for looking into this. I'll check my cross-build setup again. But I have little hope that that results in something different/useful for you in the short term (given the strangeness that the problem occurs only with Tk9.0b* and I never had it before). Therefore, I believe it's best not to wait for that, and wouldn't mind closing this ticket now as not reproducible. jan.nijtmans added on 2024-08-25 22:09:42: > 3. I checked whether tkWin.h is included in tkWinWm.c: Let's come back on that. Indeed, tkWin.h is not included in tkWinWm.c, but tkWinInt.h is. And ... tkWinInt.h is - in turn - including tkWin.h. Since I - apparently - have a different cross-compiler than you which doesn't show the problem, I cannot reproduce your problem. Since your suggested change in tkWinWm.c makes no sense to me, I don't know how to continue with this. I'm assuming there's something terribly wrong in your environment. erikleunissen added on 2024-07-30 23:20:24: Yep, it is as I suspected. I installed a newer release of headers and libraries for x86_86-mingw32 into my cross-compiler installation, and the linker problem was gone. So this is nothing for Tk to address. Remains for Tk to fix: - the compile error, along the lines of my earlier post in this ticket. - the many warnings regarding: /opt/toolchains/mingw-w64-20131228/x86_64-w64-mingw32/include/psdk_inc/intrin-impl.h: In function ‘_BitScanForward64’: ../../../SOURCES/tk9.0b2/win/../xlib/X11/X.h:74:23: warning: shadowed declaration is here [-Wshadow] typedef unsigned long Mask; ^ erikleunissen added on 2024-07-30 22:57:59: I wrote: "I checked that it is user32.lib or user32.dll which contains ChangeWindowMessageFilter." That is, I checked at: https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-changewindowmessagefilter that user.lib or user.dll ought contain ChangeWindowMessageFilter. After listing all defined symbols in libuser32.a (which is the actual library distributed with the cross-compiler), it appeared that ChangeWindowMessageFilter is not defined in there. Maybe my cross-compiler distribution is too old. To be continued ... erikleunissen added on 2024-07-30 12:27:43: I've had a look myself in the meantime and had a partial result. Here are the steps I took: 1. I found MSFLT_ADD to be defined in winuser.h (provided with the cross compiler) as follows: #if WINVER >= 0x0600 #define MSGFLT_ADD 1 #define MSGFLT_REMOVE 2 #if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP) WINUSERAPI WINBOOL WINAPI ChangeWindowMessageFilter (UINT message, DWORD dwFlag); #endif #endif 2. I found WINVER to be defined in tkWin.h as follows: #ifndef WINVER # define WINVER 0x0601 #endif #ifndef _WIN32_WINNT # define _WIN32_WINNT 0x0601 #endif #ifndef _WIN32_IE # define _WIN32_IE 0x0800 #endif 3. I checked whether tkWin.h is included in tkWinWm.c: Aha! It isn't. Therefore, I made the following change: --- tkWinWm.c.orig 2024-05-03 19:49:06.000000000 +0200 +++ tkWinWm.c 2024-07-30 13:26:53.000000000 +0200 @@ -13,6 +13,7 @@ * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ +#include "tkWin.h" #include "tkWinInt.h" #include <windows.h> #include <wtypes.h> And then the error went away. But I believe that the tkWin.h header should have been included by tkWinInt.h. Apparently it wasn't. I don't understand. => Could you inspect this further Jan? (B.t.w: it remains a riddle to mwhy nobody else gets this error when compiling for windows. ) After this change, the *compilation* proceeded to its end without errors. But there are still the very many warnings: /opt/toolchains/mingw-w64-20131228/x86_64-w64-mingw32/include/psdk_inc/intrin-impl.h: In function ‘_BitScanForward64’: ../../../SOURCES/tk9.0b2/win/../xlib/X11/X.h:74:23: warning: shadowed declaration is here [-Wshadow] typedef unsigned long Mask; (Actually it's always the same warning, but for almost each source file.) Finally, the build process then stopped again in the linking stage with: /opt/toolchains/x86_64-w64-mingw32/bin/x86_64-w64-mingw32-gcc -std=gnu11 -shared -o tcl9tk90.dll -pipe -static-libgcc -municode -Wl,--enable-auto-image-base -Wl,--out-implib,libtcl9tk90.dll.a tkConsole.o tkUnixMenubu.o tkUnixScale.o xcolors.o xdraw.o xgc.o ximage.o xutil.o tkWin3d.o tkWin32Dll.o tkWinButton.o tkWinClipboard.o tkWinColor.o tkWinConfig.o tkWinCursor.o tkWinDialog.o tkWinDraw.o tkWinEmbed.o tkWinFont.o tkWinGDI.o tkWinIco.o tkWinImage.o tkWinInit.o tkWinKey.o tkWinMenu.o tkWinPixmap.o tkWinPointer.o tkWinRegion.o tkWinScrlbr.o tkWinSend.o tkWinSendCom.o tkWinSysTray.o tkWinWindow.o tkWinWm.o tkWinX.o stubs.o tk3d.o tkArgv.o tkAtom.o tkBind.o tkBitmap.o tkBusy.o tkButton.o tkCanvArc.o tkCanvBmap.o tkCanvImg.o tkCanvLine.o tkCanvPoly.o tkCanvPs.o tkCanvText.o tkCanvUtil.o tkCanvWind.o tkCanvas.o tkClipboard.o tkCmds.o tkColor.o tkConfig.o tkCursor.o tkEntry.o tkError.o tkEvent.o tkFileFilter.o tkFocus.o tkFont.o tkFrame.o tkGC.o tkGeometry.o tkGet.o tkGrab.o tkGrid.o tkIcu.o tkImage.o tkImgBmap.o tkImgListFormat.o tkImgGIF.o tkImgPNG.o tkImgPPM.o tkImgSVGnano.o tkImgPhoto.o tkImgPhInstance.o tkImgUtil.o tkListbox.o tkMacWinMenu.o tkMain.o tkMain2.o tkMenu.o tkMenubutton.o tkMenuDraw.o tkMessage.o tkPanedWindow.o tkObj.o tkOldConfig.o tkOption.o tkPack.o tkPkgConfig.o tkPlace.o tkPointer.o tkRectOval.o tkScale.o tkScrollbar.o tkSelect.o tkStyle.o tkText.o tkTextBTree.o tkTextDisp.o tkTextImage.o tkTextIndex.o tkTextMark.o tkTextTag.o tkTextWind.o tkTrig.o tkUndo.o tkUtil.o tkVisual.o tkStubInit.o tkWindow.o ttkWinMonitor.o ttkWinTheme.o ttkWinXPTheme.o ttkBlink.o ttkButton.o ttkCache.o ttkClamTheme.o ttkClassicTheme.o ttkDefaultTheme.o ttkElements.o ttkEntry.o ttkFrame.o ttkImage.o ttkInit.o ttkLabel.o ttkLayout.o ttkManager.o ttkNotebook.o ttkPanedwindow.o ttkProgress.o ttkScale.o ttkScrollbar.o ttkScroll.o ttkSeparator.o ttkSquare.o ttkState.o ttkTagSet.o ttkTheme.o ttkTrace.o ttkTrack.o ttkTreeview.o ttkWidget.o ttkStubInit.o tk.res.o "/usr/local/src/BUILD/x86_64-mingw32/tcl9.0b2/libtclstub.a" -lnetapi32 -lkernel32 -luser32 -ladvapi32 -luserenv -lws2_32 -lgdi32 -lcomdlg32 -limm32 -lcomctl32 -lshell32 -luuid -lole32 -loleaut32 -lwinspool tkWinWm.o:tkWinWm.c:(.text+0x34f8): undefined reference to `__imp_ChangeWindowMessageFilter' collect2: error: ld returned 1 exit status make: *** [Makefile:743: tcl9tk90.dll] Error 1 I checked that it is user32.lib or user32.dll which contains ChangeWindowMessageFilter. The command line above holds -luser32, so that's fine too. I give up for this error. So, I made partial progress, but couldn't make it to the finish. A last remark: I never had such trouble cross-building. Tcl9.0, and also the previous Tk release Tk 8.6.14, build fine using the same cross-toolchain. Regards, Erik. -- jan.nijtmans added on 2024-07-20 23:33:13: I'll have a look, after my vacation |
