go-spacemesh icon indicating copy to clipboard operation
go-spacemesh copied to clipboard

Setup windows toolchain

Open sudachen opened this issue 2 years ago • 7 comments

Instruction (can be added into README.md also)

To build go-spacemesh on Windows all you need is Msys2

  1. Install msys2 from https://www.msys2.org/ and update it. Update is not necessary but strongly recommended, for update you can do next:
  • Run Msys2 shell (press Win-key once and type msys2)
  • Update msys base pacman -Syu --noconfirm
  • Run Msys2 shell again if it closed after update (it's OK)
  • Update msys pacman -Su --noconfirm
  1. To setup windows toolchain run Msys2 shell and and do next:
  • Install git and make pacman -S git make --noconfirm
  • Clone go-spacemesh repo git clone https://github.com/spacemeshos/go-spacemesh
  • Go to go-spacemesh folder cd go-spacemesh
  • Run once make setup-windows-toolchain
  1. To build go-spacemesh run Msys2 shell and do next:
  • Clone/Checkout required go-spacemesh branch
  • Run make in the go-spacemesh folder

Do not forget install VisualC++ runtime if you don't have it installed. It's used by gpu-setup.dll https://docs.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist

Motivation

Build apps with CGO on Windows is not trivial so this PR adds target into the Makefile to setup build environment.

Closes #2626

Changes

It adds new target setup-windows-toolchain to setup windows go/gcc toolchain.

sudachen avatar Sep 07 '21 11:09 sudachen

This sounds similar to my manual Win 10 pro setup. I'm going to try the instructions on a windows 10 pro machine and provide feedback as soon as I'm able to do so.

avive avatar Sep 09 '21 08:09 avive

I've followed the instructions and it mostly works - I was able to build ok on win 10 pro with some caveats. See below.

  1. Install msys2 from https://www.msys2.org/ ad update it. Update is not necessary but strongly recomended:
  • I assume you update it using the instructions you provide below - please clarify it.
  • an -> and
  • recomended -> recommended
  • Run Msys2 shell (press Win-key once and type msys)

On my system you need to type msys2 to open the msys shell, and msys command doesn't work.

Do not forget install VisualC++ 2015 runtime if you don't have it installed. It's used by gpu-setup.dll https://www.microsoft.com/en-us/download/details.aspx?id=52685

Ok, so my system had 3 c++ redists: 2008, and 2015-2019 (x64) and 2015-2019 (x86) so VC++ runtime fails to install over these (one has to dig into install logs to find out why in typical ms UX). Are we sure want to ask users to install this ancient runtime? Won't the 2015-2019 runtime work? Ideally we can ask users to install the latest VC++ runtime and it will work.

@moshababo @sudachen

avive avatar Sep 09 '21 12:09 avive

Really, user must have any VC140 compatible runtime. By default, windows10 does not have it. So, Yes, VC2019 will work well.

I'm not sure why searching in menu does not work with just typing msys, however, yes, msys2 must work well too.

sudachen avatar Sep 09 '21 13:09 sudachen

so we need to recommend the most recent vc++ runtime that ms makes available that will work.

avive avatar Sep 09 '21 13:09 avive

I will check it on clean system with VC2019 runtime today, to be sure.

sudachen avatar Sep 09 '21 13:09 sudachen

bors try

sudachen avatar Nov 13 '21 00:11 sudachen

try

Build succeeded:

bors[bot] avatar Nov 13 '21 01:11 bors[bot]