Fix console output on windows

By default, stdout and stderr disappear completely for windows GUI programs.
This is rather unhelpful when using or debugging displaz from the console, so
re-attach to the parent console if it's present after startup.  This lets us
get console messages, while also avoiding an annoying extra window when started
normally via the GUI.
Autodetect version number when built from git tree