Cannot run debug in VsCode. Error while loading shared libraries - visual-studio-code

Im trying run program in debug.
The program is compiled with cmake conan.
My config vscode:
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/bin/program",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "gnu17",
"cppStandard": "gnu++17",
"intelliSenseMode": "linux-gcc-x64"
}
],
"version": 4
}
Error:
/home/user/git_repos/program/build/bin/program: error while loading shared libraries: libQt5Core.so.5: cannot open shared object file: No such file or directory
[1] + Done "/usr/bin/gdb" --interpreter=mi --tty=${DbgTerm} 0<"/tmp/Microsoft-MIEngine-In-mezeyszy.sh4" 1>"/tmp/Microsoft-MIEngine-Out-nbctgvn3.1sn"
I have all of this files, how i can show path to it for vscode? Or if this does not help solve the problem, then what are the ways and what could be the problem?

Related

using external terminal vscode windows

I'm using VS Code with C, when i run,i wanna instead of using the integrated terminal in vscode, use an external terminal(cmd), i configurated my launch.json with "externalConsole": true, and in my settings.json, I use {"terminal.external.windowsExec": "C:\\Windows\\system32\\cmd.exe",}, but nothing happen.
launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Iniciar",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}\\bin\\main.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "C:\\Program Files\\CodeBlocks\\MinGW\\bin",
"setupCommands": [
{
"description": "Habilitar a reformatação automática para gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Definir Tipo de Desmontagem como Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
}
]
}
settings.json:
{"terminal.external.windowsExec": "C:\\Windows\\system32\\cmd.exe",}

How to debug and run c++ in vs code

I have even checked my environment variables path its correct, tried uninstalling vs code many times same, issue
everytime i i get output
C/MingW/bin/g++.exe : The term '/C/MingW/bin/g++.exe' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
/C/MingW/bin/g++.exe -g 'c:\Users\sayye\Dropbox\My PC (LAPTOP-T1S5QOV ...
+ CategoryInfo : ObjectNotFound: (/C/MingW/bin/g++.exe:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
my c_cpp_properties.json
{
"configurations": [
{
"name": "windows-gcc-x86",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "gcc",
"cStandard": "${default}",
"cppStandard": "${default}",
"intelliSenseMode": "windows-gcc-x86",
"compilerArgs": [
"-Wall",
"-Wextra",
"-Wpedantic"
]
}
],
"version": 4
}
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "g++.exe - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++.exe build active file"
},
{
"name": "C/C++ Runner: Debug Session",
"type": "cppdbg",
"request": "launch",
"args": [],
"stopAtEntry": false,
"cwd": "c:\\Users\\sayye\\Dropbox\\My PC (LAPTOP-T1S5QOVG)\\Desktop\\Dump_codes\\c++",
"environment": [],
"program": "c:\\Users\\sayye\\Dropbox\\My PC (LAPTOP-T1S5QOVG)\\Desktop\\Dump_codes\\c++\\build\\Debug\\outDebug",
"internalConsoleOptions": "openOnSessionStart",
"MIMode": "gdb",
"miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
"externalConsole": false,
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
Task.json
{
"tasks": [
{
"type": "shell",
"label": "C/C++: g++.exe build active file",
"command": "C:/MingW/bin/g++.exe",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
}
}
],
"version": "2.0.0"
}
setting.json
{
"files.associations": {
"iostream": "cpp"
},
"C_Cpp.errorSquiggles": "Disabled",
"C_Cpp_Runner.cCompilerPath": "gcc",
"C_Cpp_Runner.cppCompilerPath": "C:\\MinGW\\bin\\g++.exe",
"C_Cpp_Runner.debuggerPath": "C:\\MinGW\\bin\\gdb.exe",
"C_Cpp_Runner.makePath": "C:\\MinGW\\bin\\make.exe",
"C_Cpp_Runner.warnings": [
"-Wall",
"-Wextra",
"-Wpedantic"
],
"C_Cpp_Runner.compilerArgs": [],
"C_Cpp_Runner.includePaths": [],
"C_Cpp_Runner.linkerArgs": [],
"C_Cpp_Runner.cStandard": "",
"C_Cpp_Runner.cppStandard": "",
"C_Cpp_Runner.excludeSearch": [],
"C_Cpp_Runner.enableWarnings": true,
"C_Cpp_Runner.warningsAsError": false
}
I want to get my output in vs code integrated terminal

How can i solve "unable to open 'read.c': Unable to read file..." in vscode ubuntu

I'm trying to debug my C program in VScode, then this error appears
How can I fix it?
Unable to open 'read.c': Unable to read file '/build/glibc-eX1tMB/glibc-2.31/sysdeps/unix/sysv/linux/read.c' (Error: Unable to resolve non-existing file '/build/glibc-eX1tMB/glibc-2.31/sysdeps/unix/sysv/linux/read.c').
launch.json file:
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "g++ - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/a.out",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++ build active file",
"miDebuggerPath": "/usr/bin/gdb",
"sourceFileMap": {
"/build/glibc-YYA7BZ": "/usr/src/glibc"
}
}
]
}
tasks.json file:
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: gcc-9 build active file",
"command": "/usr/bin/gcc-9",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
},
{
"type": "cppbuild",
"label": "C/C++: gcc build active file",
"command": "/usr/bin/gcc",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": "build",
"detail": "compiler: /usr/bin/gcc"
}
],
"version": "2.0.0"
}

My code doesn´t stop at breakpoints while debugging C++ in visual studio code

My IDE is not stoppping at Breakpoints. I can´t navigate trought the code.
I don´t know how to proceed.
I´m a Engineering student.
This is the launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "g++.exe - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [
"run",
"debug",
],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:\\Program Files (x86)\\Falcon\\MinGW\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++.exe build active file"
}
]
And this is the tasks.json
{
"tasks": [
{
"type": "shell",
"label": "C/C++: g++.exe build active file",
"command": "C:\\Program Files (x86)\\Falcon\\MinGW\\bin\\g++.exe",
"args": [
"-Wall",
"-Wextra",
"-g",
"*.cpp",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
}
}
],
"version": "2.0.0"
}
I would aprecciate any help you guys could give.

Debugging with Bazel in Visual Studio Code with Ubuntu

I read this Bazel VS Code tutorial.
Currently, I have a problem with reproducing the tutorial on my system.
I am using Ubuntu 18.04 and bazel 0.27.0 and Visual Studio Code (Version 1.35.1)
My files:
tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"label": "Build Example (Debug)",
"type": "shell",
"command": "bazel build :example -c dbg",
"linux": {
"command": "bazel build :example -c dbg --spawn_strategy=standalone",
},
"group": {
"kind": "build",
"isDefault": true
},
}
]
}
My launch.json:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Example",
"type": "cppdbg",
"request": "launch",
"preLaunchTask": "Build Example (Debug)",
"program": "${workspaceFolder}/bazel-out/k8-dbg/bin/example",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/bazel-out/k8-dbg/bin/example.runfiles/__main__/",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"sourceFileMap": {
"/home/newton/.cache/bazel/_bazel_newton/7a12d285425fc99da0ce87e2a08f2f36/execroot/__main__/": "${workspaceFolder}"
}
}
]
}
The following screenshot shows in the lower left corner that an error is reported when I try to start debugging: "Unable to read file (Error: File not found..."
I am looking for any suggestion on how to fix this and to make it work.
See this.
Here's my config:
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",
"type": "shell",
"command": "bazel build --compilation_mode=dbg //...",
"group": {
"kind": "build",
"isDefault": true
},
}
]
}
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "ExampleMihai",
"preLaunchTask": "build",
"type": "cppdbg",
"request": "launch",
"program": "/home/mihai/.cache/bazel/_bazel_mihai/89c1625b12241e64b746e0e58fdc7159/execroot/__main__/bazel-out/k8-dbg/bin/unit/test_static_string",
"args": [],
"stopAtEntry": false,
"cwd": "/home/mihai/git/containers",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": false
}
]
},
]
}
I use sourceFileMap to fix the "unable to read file" error on Linux. The following configuration uses the "official" paths in bazel-bin/:
{
"version": "0.2.0",
"configurations": [
{
"name": "launch",
"type": "cppdbg",
"preLaunchTask": "build",
"request": "launch",
"program": "${workspaceFolder}/bazel-bin/example/example",
"cwd": "${workspaceFolder}/bazel-bin/example/example.runfiles/__main__",
"linux": {
"sourceFileMap": {
"/proc/self/cwd": "${workspaceFolder}",
}
}
}
]
}