Golang, QT Binding, Gocode, VSCode, in Windows 10 Oh My

Ok, so this will be a long series of posts but I was stubborn and I really wanted a particular setup to work.

Wanted / Goal:

  • I wanted to code a large cross platform desktop project in go.
  • I wanted to use QT for the GUI
  • I wanted to do primary development in a windows 10 environment (as this is the platform I am usually sitting at)
  • I wanted to use VSCode for development editor

Initial problems:

  • There are several experiments for cross platform GUI either in native go, or with go bindings.  The short list of what I researched is electron via go-thrust, wx, shiny, gxui, walk, andlabs, several of these have or have had potential, most sort of atrophied over time as cross platform GUI = Hard, I settled eventually on QT but only because the binding work by therecipe available here is both current, and exceptionally well integrated.
  • Using the default QT binaries at the time 5.70 while it work well in linux, os x, for windows the delivered opensource binaries were only the 32bit version, and while therecipe’s build system handled this well even with a 64 bit golang, he cross compiled automagically, but you of course ended up with a 32bit application.
  • Additionally the go tool gocode that handles the service piece that does the intellisense magic for VSCode, wouldn’t handle in the editor having a default go for amd64 while introspecting into x86 binaries.  I just couldn’t get to work with a go application compiled down to x86 when the default was amd64, etc. So I wasn’t getting any of the intellisense type of stuff.
  • This becomes a particular pain point because the QT libraries themselves are massive, and the strongly typed binding magic makes coding difficult when you have to constantly open up other source files to search for methods, parameters etc.
  • What really needed to happen was having a 64bit version of the QT libraries as well as a gcc that would build and bind with go toolchains for all amd64.
  • Building windows version of Qt from source is particularly challenging, and most info for windows building is either about doing so with Visual Studio or the mingw32 builds that they already binaries for, that won’t work for my goal.
  • I don’t even think a Visual Studio build of Qt would work binding to Go IMHO, stuff about SEH, DWARF, SJlJ, and probably a bunch of other letters keep getting in the way 🙂
  • Finding picking, and getting Qt to build with things like mingw64, TCC-64, Qt64-NG, the project etc. seemed like a real challenge as the efforts again had atrophied, or the build process was for older versions of Qt, etc.

Therecipe eventually offered an MSYS2 parameter in his build setup, and utilizing this is where I finally made some traction on my goals of a decent setup in windows where the intellisense stuff works etc.  And while Therecipe gives instructions on using msys2 there where some extra steps along the way to get it all to work.  An additional advantage is the current, as of this post, version of QT building on the MSYS2 64bit environ is 5.8 (the latest).

Steps taken overview:

Here is an outline of each of the posts I’ll do about this setup.  Feel free to jump around, but I have only tested this by doing this in order:

  1. Installing regular golang binary in windows 10 and setting up path environments.
  2. Installing MSYS2, updating, installing build tools, and toolchains, and Qt 5.8 64 bit
  3. Configuration of Golang with MSYS2 MingW64
  4. Installing thereciepe QT Bindings
  5. Installing VSCode and Go extensions and setting up integrated terminal

 

Leave a Reply

Your email address will not be published. Required fields are marked *