Tk Source Code

View Ticket
Login
Ticket UUID: fcfd9a84d424e878ea03759d2776003dc27e7b3b
Title: Tk does not build under Visual Studio 2017 and higher (solved)
Type: Support Version: 8.6.9
Submitter: hant Created on: 2019-04-24 10:30:35
Subsystem: 85. Win Build Assigned To: jan.nijtmans
Priority: 5 Medium Severity: Important
Status: Closed Last Modified: 2019-07-29 09:26:17
Resolution: Out of Date Closed By: jan.nijtmans
    Closed on: 2019-07-29 09:26:17
Description:

There is a problem with compiling Tk in Visual Studio. This was already mentioned in ticket 3d34589aa0. It was reported to be solved, but this is not yet the case as I experienced with release 6.8.9, using buildall.vc.bat (+VS2019).
It seems that the definitions in Visual Studio have slightly changed.

The best thing to avoid future collisions with windows is to check all C-files that use windows.h and put <windows.h> on the first line. So at the moment, writing:
#include <tkInt.h>
#include <windows.h>

instead of the other way around leads to this confusing error message. The following files need a rewrite:
winMain.c
tkWinSendCom.c
tkWinSend.c
tkWinInt.h
tkWin.h
and
tkCmds.c
tkWindow.c
tkStubInit.c
tkTextDisp.c
tkPointer.c
tkListbox.c
tkImgPhoto.h
tkGrab.c
tkCanvasPs.c
tkBind.c
tkConsole.c
Furthermore, you might need to add /D_WIN32 /DWIN32 /D_WINDOWS to COMPILERFLAGS in rules.vc.
Now the code will compile, but wish might still fail to run. If this is the case, the reason is that the entry point is not of the correct type.

So, as a final step, you must replace WinMain in winMain.c by wWinMain as the correct WinMain version.

User Comments: jan.nijtmans added on 2019-07-29 09:26:17:
Well, I installed the latest Visual Studio (2019), and built everything (both Tcl and Tk) using buildall.vc.bat.  The only issue I encountered is that the helpfiles were not generated (because I didn't have the help tools installed). But everything else built fine, also in shared/static/debug modes.

So, closing now. Unless Microsoft breaks something else, it's not worth to do work making it Microsoft-change-proof ;-) Things can break anytime...

Please try it with Tcl 8.6.10 (or fossil trunk). We know it doesn't work with the released 8.6.9 (or 8.6.9.1).

chrstphrchvz added on 2019-07-27 16:11:04:

Fixed link in description.


jan.nijtmans added on 2019-04-24 19:28:02:
I'm on holiday now, but after that I'll have a look again. As far as I know, all tips of the active branches are OK (they were OK - at least - about one week ago)

fvogel added on 2019-04-24 19:13:30:
Jan could you perhaps have a look? I think you did the work in the previous tickets, with Ashok. Can you dig into this, or Ashok?