Skip to content

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

  • scoop:

    powershell
    scoop install xmake
  • chocolatey:

    powershell
    choco  install xmake
  • Verify:

    powershell
    xmake --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 mogan

Use xmake to configure and build

xmake project configuration

powershell
xmake config --yes -vD -m releasedbg --plat=windows --vs_runtime=MT

If previous build failed, clear old cache first

powershell
xmake f -c
xmake c -a

Build project

powershell
xmake build stem

Install target

powershell
xmake install stem

Run program

powershell
xmake run stem

Optional: 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 ./.vscode

then 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"
        }
    ],
}
}

Enjoy exploring science and technology!