-
Notifications
You must be signed in to change notification settings - Fork 30
Windows dev
- MSVC
- How to delete/change/whatever files in
C:\Windows\System32
- Path lengths
- Developer's shell
- Boost
- WDK/SDK
- Driver signing
Table of contents generated with markdown-toc
DO NOT USE MSVC FOR ANYTHING. Use clang-cl.exe
instead - it can be installed through the Visual studio installer and selected by setting e.g.,
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\Llvm\x64\bin\clang-cl.exe
Note, if you get an error like
lld-link: error: <root>: undefined symbol: _mainCRTStartup
that's (likely) because you've selected the win32 toolchain/compiler:
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\Llvm\bin\clang-cl.exe
Notice the absence of the x64.
Start an admin pwsh
(or cmd
) and
takeown /f <file>
icacls <file> /grant <username>:F
Then do what you wish.
More at SO
If you get errors like cannot find file: ''
even though the file is infact where it should be then you're running into Windows 256 character path length limit. Yes, really. There's a horrendous amount of blood/ink spilled on the matter but TL;DR there's nothing to be done about it - move your build directory to something like C:\bui
and shorten your filenames.
Note: sometimes things will fail mysteriously for this reason. If it's somewhere near a path lookup like elf loading in aie-rt
:
[AIE ERROR] XAie_LoadElfPartial():602: Unable to open elf file, 2: No such file
then it's probably this same stupid blocker/issue. Do a std::cerr << path
and if the path is correct going in then it's almost certainly this issue. Again: nothing to be done about it, just move/rename things.
If you're getting errors/problems about win32 compilation or whatever it's because your developer shell isn't defaulting to x64. You can add -Arch amd64 -HostArch amd64
to the shortcut or create a new shortcut with this "target"
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -noe -c "&{Import-Module """C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"""; Enter-VsDevShell 941e2056 -Arch amd64 -HostArch amd64}"
Note the 941e2056
is specific to your system; you can figure it out by finding the conventional Developer PowerShell shortcut at somewhere like
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2022\Visual Studio Tools
right click it, Properties -> Target
.
We build Boost from source but if you need to have a system install for some other project (eg XRT) then
- Download the Boost installer for 1.75 MSVC 14.2 here
- Install to somewhere like
C:\local\boost_1_75_0
- Rename
C:\boost_1_75_0\lib64-msvc-14.2
toC:\boost_1_75_0\lib
- Use
-DBOOST_ROOT=C:\boost_1_75_0
- If that doesn't work try some of the "hints" here
Download the "Windows Driver Kit".
Make sure you have the matching SDK version (eg 10.0.26100.1
) installed/downloaded.
If you did this and build.bat
is still complaining about not finding WindowsKernelDevelopmentModule
(or something like that) then try
# pswh
cd "C:\Program Files (x86)\Windows Kits\10\Vsix\VS2022\10.0.26100.0\amd64"
.\WDK.vsix
and if that complains and tells you that you should install through the Visual Studio installer then startup Visual Studio installer, click modify
and then switch to the Individual components
tab:
Enable "testsigning"
:: cmd.exe
bcdedit /set testsigning on
Install the driver's test certificate
# pwsh
cd "C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\x64"
certmgr.exe -add ipukmddrv.cer -r localMachine -s root
You should use git-bash
for things - it's not posix but it's good enough. Note, if you have it installed but a cmd
shell or powershell
session doesn't find it (bash: command not found
) then you need to add it to your path (see SO):
# cmd
SET "PATH=C:\Program Files\Git\bin;%PATH%"
# powershell
$env:PATH += ";C:\Program Files\Git\bin"