Developing for Windows
Step 1: Install tools and dependencies
Install Visual Studio 2022 (MSVC 14.44.35211)
- Install workload: "Desktop development with C++"
- Check:
- MSVC 14.44.35211
- Windows 10/11 SDK
- Open VS Installer, select Desktop development with C++
- Check MSVC, Windows 10/11 SDK
- After installation, launch VS once to initialize components
Install xmake
Recommended to install using scoop or choco. Choose either:
scoop:
powershellscoop install xmakechocolatey:
powershellchoco install xmakeVerify:
powershellxmake --version
Step 2: Get source code and compile run
Choose your own working directory, for example E:\TestFile:
powershell
cd E:\TestFile
git clone git@gitee.com:XmacsLabs/mogan.git
cd moganUse xmake to configure and build
xmake project configuration
powershell
xmake config --yes -vD -m releasedbg --plat=windows --vs_runtime=MTIf previous build failed, clear old cache first
powershell
xmake f -c
xmake c -aBuild project
powershell
xmake build stemInstall target
powershell
xmake install stemRun program
powershell
xmake run stemOptional: Vscode support
Developers using Vscode can use xmake to generate compile_command.json, which can be recognized by C/C++ plugin to provide semantics highlight and so on.
bash
xmake project --kind=compile_commands ./.vscodethen modify .vscode/c_cpp_properties.json to tell C++ lsp configs of this project:
jsonc
{
{
"configurations": [
{
// other configs
"compilerPath": "<your configuration>",
"cppStandard": "gnu++17",
"intelliSenseMode": "windows-gcc-x64",
"compileCommands": ".vscode/compile_commands.json"
}
],
}
}