QT+MinGW+VS code 环境搭建

    xiaoxiao2022-07-15  162

    qt-opensource-windows-x86-5.9.8.exe(里面会包含MinGW的安装)

    VSCodeUserSetup-x64-1.34.0.exe

    cmake-3.14.4-win64-x64.msi (使用cmake编译需要用到)

    以上三个软件安装好之后我们需要将MinGW 53和CMake的路径加入到Path系统环境变量中,如下:

    1.QT新建cmake编译工程

    新建完工程名后我们选择使用cmake编译

    kit选择Desktop Qt 5.9.8 MinGW 32bit

    这样的一个在QT中创建的cmake编译工程就是如上所示。

    1.1. QT中的cmake工程的gdb调试方法:

    创建完如上的cmake工程后,首先我们将工程切换为Debug状态

    接下来点击 构建->执行CMake,完成后点击Debug按钮便可以进行单步调试

    我们也可以将这个工程拷贝到linux上进行编译

    2. vs code编译调试

    launch.json

    { "version": "0.2.0", "configurations": [ { "name": "(gdb) Launch", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/a.exe", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": false, "MIMode": "gdb", "miDebuggerPath": "C:\\Qt\\Qt5.9.8\\Tools\\mingw530_32\\bin\\gdb.exe",//MinGW gdb路径 "setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true } ], "preLaunchTask":"build test"// test为编译的文件名 } ] }

    tasks.json

    { // See https://go.microsoft.com/fwlink/?LinkId=733558 // for the documentation about the tasks.json format "version": "2.0.0", "tasks": [ { "label": "build test",// test为编译的文件名 "type": "shell", "command": "g++", "args": ["-g","test.cpp"],// 编译的文件 "group": { "kind":"build", "isDefault": true} } ] }

     

    最新回复(0)