This is a list of problems experienced when setting up a Windows build environment, and how they were resolved. Perhaps people can chime in on whether I made any mistakes along the way and should be doing things differently. Otherwise, this could be useful for the googlers!
Note that the errors I faced are largely down to external software versions throwing a spanner in the works, and will likely be resolved in time as KiCad catches up with Python versions and Visual Studio implements compiler fixes. However for end of October '24, these are issues that a new developer can expect to run into.
A number of the steps are direct from the Windows (Visual Studio) build guide, others are my best guesses.
The steps I followed:
- Installed latest Visual Studio with the C++ toolset and CMake tools for Windows.
- Created a fork of the repo ā/kicad/code/kicadā into my own gitlab account
- Cloned the forked repo onto my computer
- Cloned vcpkg onto my computer
- Copied the KiCad CMakeSettings.json.sample to CMakeSettings.json
- Edited the KiCad CMakeSettings.json to update the following to point to my vcpkg
{ āVcPkgDirā: āD:/vcpkg/ā }
- Opened the KiCad folder in Visual Studio - CMake started downloading / compiling dependencies. This takes some time.
This led to the first error:
error: building wxpython:x64-windows failed with: BUILD_FAILED
A little higher up in the build log are instructions to investigate get-pip-x64-windows-err.log
for more information. This logfile contains the error ModuleNotFoundError: No module named ādistutilsā
.
NOTE that the following fix will go out of date when KiCad catches up to the Python version in vcpkg
Marekr helped me sort this out. It seems vcpkg updated the default Python version sometime in October, and the new version removes the depreciated distutils. The solution was to checkout an earlier version of vcpkg. I chose to go with the last commit in September.
I use TortoiseGit for these things, and Iām not in any way an expert (but Iām learning!) so for reference, the way to downgrade to an earlier version of the repo in TortoiseGit was to right-click in the vcpkg folder to get to TortoiseGit context menu and select āShow Logā. Then right-click on one of the log entries (in my case, last one for September '24) and select āReset Master to Thisā. Finally - and the bit that tripped me up - select the checkbox for a Hard: Reset working tree and index.
To verify that this worked, check the contents of vcpkg/scripts/cmake/vcpkg_find_acquire_program(PYTHON3).cmake
doesnāt reference Python 3.12.x.
At this point, I deleted my KiCad clone and cloned it again to make sure it was fresh. Probably didnāt need to, but seemed a good ideaā¦
Then back to Step 7:
- Opened the KiCad folder in Visual Studio - CMake started downloading / compiling dependencies. This takes some time.
- Downloaded swig (got version 4.1.1 to avoid any other version issues)
- Updated the CMakeSettings in VS to point to SWIG
- Optimistically hit the Build All
And another error! This time, it was when compiling pcbnew_wrap.cxx (generated by SWIG). Something about āexpected an expression instead of a typeā (I neglected to get this error verbatim, sorry).
This error turned out to be the MS compiler having bugs. I was using the release version, 17.11.5. Finding an open issue on GitLab led me to change my VS version (in VS, Help->Check for Updates, and in that window, āChange update settingsā, then shift the update channel to preview which as of writing was 17.12.0 preview 5). Obviously this is a very time-specific fix and will be out of date when VS pushes the fixes to the release - but hopefully at this point, the error will no longer happen anyway!
So, following this fix, back to step 7:
7) Opened the KiCad folder in Visual Studio - CMake started downloading / compiling dependencies. This takes some time - even more so because new VS recompiles all dependencies again.
8) Already have SWIG
9) Already set SWIG up in CMakeSettings
10) A little less optimistically hit the Build All
And eventually, after everything seemed to be going so well, I got āBuild All Failedā. Scrolling all the way to the top of the output, I discovered fatal: No names found, cannot describe anything.
So - final fix. I tracked this error down to there being no tags in my fork of KiCad. To get the tags cloned across, I found the following instructions (command line Git usage here). MyKicadCloneDir is the directory in which I cloned KiCad:
> cd MyKicadCloneDir > git remote add upstream https://gitlab.com/kicad/code/kicad.git > git fetch upstream > git rebase upstream/master > git push > git push --tags
The final command hung on me first time I used it - so after 10 minutes of no activity, I hit Ctrl+C to cancel it and ran it again.
Following all this, I can see in the web browser that my fork of KiCad now has tags, and the command git describe --tags
works now.
Finally, step 10)
10) Slightly more optimistically hit the Build All
And horray! Build succeeded.
I hope this huge post is more useful than annoying, even though much of it will go out of date as software versions progress. But in the meantime, I know if Iād found this post while googling, Iād have been very happy!