在VS代码中交叉编译Windows与Linux上的MinGW的SDL程序

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

本文关键字:MinGW 上的 SDL 程序 Linux 代码 VS 交叉编译 Windows      更新时间:2023-10-16

我想创建一个带有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"
}

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