I'm using Visual Studio Code (1.103.0) for Linux (ubuntu 24-04-2 LTS) with Qt qmake instead of cmake. I am having trouble getting the IDE to build and launch a release version of my code. No matter what I do, I get a debug build. I have tested all sorts of solutions and diagnostic tests with the assistance of Microsoft CoPilot, but we are unable to get it to work.
here is my launch.json file ...
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch Pegs (Debug)",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/debug/Pegs",
"preLaunchTask": "Build Debug",
"cwd": "${workspaceFolder}",
"MIMode": "gdb",
"stopAtEntry": false,
"args": []
},
{
"name": "Launch Pegs (Release)",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/release/Pegs",
"preLaunchTask": "Build Release",
"cwd": "${workspaceFolder}",
"MIMode": "gdb",
"stopAtEntry": false,
"args": []
}
]
}
Here is my tasks.json file ...
{
"version": "2.0.0",
"tasks": [
{
"label": "Build Debug",
"type": "shell",
"command": "echo Debug && sleep 1 && qmake Pegs.pro CONFIG+=debug && make",
"options": {
"cwd": "${workspaceFolder}"
},
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": []
},
{
"label": "Build Release",
"type": "shell",
"command": "echo Release && sleep 1 && qmake Pegs.pro CONFIG+=release && make",
"options": {
"cwd": "${workspaceFolder}"
},
"group": {
"kind": "build"
},
"problemMatcher": []
},
{
"label": "releaseBuildRun",
"type": "shell",
"command": "${workspaceFolder}/releaseBuildRun.sh",
"problemMatcher": [],
"presentation": {
"reveal": "always"
},
"group": {
"kind": "none"
}
}
]
}
and here is my project.pro file ...
CONFIG += c++17
SOURCES += src/main.cpp
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG(debug, debug|release) {
DESTDIR = build/debug
OBJECTS_DIR = build/debug/obj
MOC_DIR = build/debug/moc
RCC_DIR = build/debug/rcc
UI_DIR = build/debug/ui
} else {
DESTDIR = build/release
OBJECTS_DIR = build/release/obj
MOC_DIR = build/release/moc
RCC_DIR = build/release/rcc
UI_DIR = build/release/ui
}
# Default to debug if no mode is specified
!CONFIG(release):!CONFIG(debug) {
CONFIG += debug
}
I can select the desired configuration with <Ctrl><Shift>D and choosing the debug or release path. It does not matter what I choose - I always get the debug build/run. I also played with the isDefault attribute but that did not make any difference.
I wrote simple bash scripts thata execute the desired steps, namely "qmake Pegs.pro CONFIG+=release" and then "make". This works well, but I would like the IDE to respect my choice.
Thank you for your attention to this question. I hope someone out there has an answer.
Choose Ctrl-Shift-D, then choose debug or release, and then press F5. The system "remembers" the debug/release selection. Each time you subsequently press F5, you get a debug or release build that is remembered from the initial selection.