简体   繁体   English

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

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

I would like the create a IDE with VSCodium where I can cross compile programms for Linux and Windows on Linux.我想用 VSCodium 创建一个 IDE,我可以在其中交叉编译 Linux 和 Windows 上的 Linux 程序。 I would like to use SDL2 with it but i have problems to do that with MinGW and g++ for Windows.我想将 SDL2 与它一起使用,但我在使用 Windows 的 MinGW 和 g++ 时遇到问题。 Maybe someone knows the right g++ command for that.也许有人知道正确的 g++ 命令。 Currently i got this:目前我得到了这个:

{
    // 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"
}

If you got the same Problem like me it is easier to use some extern software to do the compiling (writing a shellscript or using make).如果您遇到和我一样的问题,使用一些外部软件进行编译会更容易(编写 shellscript 或使用 make)。 Because if you have a bigger project you can easily run in problmes.因为如果你有一个更大的项目,你可以很容易地在问题中运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM