C++ 在VS代码中使用Linux上的MinGW交叉编译Windows的SDL程序?
我想用VSCodium创建一个IDE,在那里我可以在Linux上交叉编译Linux和Windows程序。我想使用SDL2,但我在使用MinGW和g++for Windows时遇到了问题。 也许有人知道正确的g++命令。现在我得到了这个:C++ 在VS代码中使用Linux上的MinGW交叉编译Windows的SDL程序?,c++,visual-studio-code,g++,mingw,sdl,C++,Visual Studio Code,G++,Mingw,Sdl,我想用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":
{
// 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)会更容易。因为如果你有一个更大的项目,你可以很容易地在问题中运行。我自己解决了问题,并编写了一个shell脚本,效果很好。你为什么不想共享它呢?我可以共享它,但它只在我的环境中工作,因为它将我所有的依赖项放在一起并构建它。因此,它对其他人没有多大用处。我只需要正确的构建命令就可以了。就像我说的,使用make或其他构建工具可能会更好。