【问题标题】:Cross-compile SDL programs for Windows with MinGW on Linux in VS Code?在 VS Code 中使用 Linux 上的 MinGW 交叉编译适用于 Windows 的 SDL 程序?
【发布时间】:2020-02-26 04:12:36
【问题描述】:

我想用 VSCodium 创建一个 IDE,我可以在其中交叉编译 Linux 和 Linux 上的 Windows 程序。我想将 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 或其他构建工具可能会更好。

标签: c++ visual-studio-code g++ mingw sdl


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-04-18
    • 1970-01-01
    • 1970-01-01
    • 2012-09-24
    • 1970-01-01
    • 2015-03-25
    相关资源
    最近更新 更多