在 VS Code 中使用 Linux 上的 MinGW 交叉编译 Windows 的 SDL 程序?

Cross-compile SDL programs for Windows with MinGW on Linux in VS Code?

我想用 VSCodium 创建一个 IDE,我可以在其中为 Linux 和 Windows 在 Linux 上交叉编译程序。我想将 SDL2 与它一起使用,但我在使用 MinGW 和 g++ for Windows 时遇到问题。 也许有人知道正确的 g++ 命令。目前我得到这个:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build-C++-SLD2-Linux",
            "type": "shell",
            "command": "g++",
            "args": [
                "-g",
                "*.cpp",
                "-I/usr/include/SDL2",
                "-lSDL2",
                "-o",
                "App.exe"
            ],
            "group": "build"
        },
        {
            "label": "build-C++-SLD2-Windows",
            "type": "shell",
            "command": "g++",
            "args": [
                "*.cpp",
                "-I/usr/include/SDL2",
                "-lSDL2",
                "-lSDL2main",
                "-L/usr/x86_64-w64-mingw32/bin",
                "-o",
                "AppWin64.exe"

            "group": "build"
            ],
        },
        {
            "label": "build-C++-SLD2-Windows-alt",
            "type": "shell",
            "command": "x86_64-w64-mingw32-g++",
            "args": [
                "-g",
                "*.cpp",
                "-I/home/username/Dokumente/SDL2",
                "-L/home/username/Dokumente/lib",
                "-L/usr/x86_64-w64-mingw32/bin",
                "-lSDL2",
                "-o",
                "AppWin.exe"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ],
    "group": {
        "kind": "build",
        "isDefault": true
    },
    "problemMatcher":"$gcc"
}

如果你和我有同样的问题,使用一些外部软件来编译(写一个shellscript或使用make)会更容易。因为如果你有一个更大的项目,你可以很容易地 运行 遇到问题。