I am working with gtk+ application in cpp ,I want Bastler Pylon integration with gtk and I found by lots of research Gtk+ application uses MinGw compiler and Pylon uses MSVC compiler My problem is to run a gtk+ code into vscode ide,I never used vscode before I usually use sublime text editor in ubuntu and I want above integration in windows....
my four file structure are below...
c_cpp_properties.json
{
"configurations": [
{
"name": "Gtk_dev",
"includePath": [
"${workspaceFolder}/**",
"C:/msys64/mingw64/include/**",
"C:/msys64/mingw64/lib/glib-2.0/include"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "C:/msys64/mingw64/bin/gcc.exe",
"cStandard": "gnu17",
"cppStandard": "gnu++14",
"intelliSenseMode": "gcc-x64",
"compilerArgs": [],
"browse": {
"limitSymbolsToIncludedHeaders": false,
"path": []
}
}
],
"version": 4
}
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "g++.exe - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "C:\\msys64\\mingw64\\bin",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:\\msys64\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++.exe build active file"
}
]
}
tasks.json
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "C/C++: gcc.exe build active file",
"command": "g++",
"args": [
"-g",
"-pthread",
"-mms-bitfields",
"-IC:/msys64/mingw64/include/gtk-3.0",
"-IC:/msys64/mingw64/include/cairo",
"-IC:/msys64/mingw64/include",
"-IC:/msys64/mingw64/include/pango-1.0",
"-IC:/msys64/mingw64/include/fribidi",
"-IC:/msys64/mingw64/include/atk-1.0",
"-IC:/msys64/mingw64/include/lzo",
"-IC:/msys64/mingw64/include/freetype2",
"-IC:/msys64/mingw64/include/libpng16",
"-IC:/msys64/mingw64/include/harfbuzz",
"-IC:/msys64/mingw64/include/pixman-1",
"-IC:/msys64/mingw64/include/gdk-pixbuf-2.0",
"-IC:/msys64/mingw64/include/glib-2.0",
"-IC:/msys64/mingw64/lib/glib-2.0/include",
"${C:/msys64/mingw64/bin/g++}",
"-LC:/mingw64/lib",
"-lgtk-3",
"-lgdk-3",
"-lz",
"-lgdi32",
"-limm32",
"-lshell32",
"-lole32",
"-luuid",
"-lwinmm",
"-ldwmapi",
"-lsetupapi",
"-lcfgmgr32",
"-lpangowin32-1.0",
"-lpangocairo-1.0",
"-lpango-1.0",
"-lharfbuzz",
"-latk-1.0",
"-lcairo-gobject",
"-lcairo",
"-lgdk_pixbuf-2.0",
"-lgio-2.0",
"-lgobject-2.0",
"-lglib-2.0",
"-lintl",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "C:/msys64/mingw64/bin"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
}
},
{
"type": "cppbuild",
"label": "C/C++: g++.exe build active file",
"command": "C:\\msys64\\mingw64\\bin\\g++.exe",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "C:\\msys64\\mingw64\\bin"
},
"problemMatcher": [
"$gcc"
],
"group": "build",
"detail": "compiler: C:\\msys64\\mingw64\\bin\\g++.exe"
}
]
}
Error showing.................by Pressing for compile and run(ctr+shift+B)..The major problem is there is no mention which file has an error
g++.exe: error: .0: No such file or directory
g++.exe: error: .0: No such file or directory
g++.exe: error: .0: No such file or directory
g++.exe: error: .0: No such file or directory
.....some included files output.....
I ran into the same error yesterday. The error message actually hints at what is wrong (.0). Some of the linked libs (-l) have .0 in their name which seems to be a problem (at least on windows). Putting the respective libs into single quotation marks does the trick:
tasks.json
[...]
"-lcfgmgr32",
"'-lpangowin32-1.0'",
"'-lpangocairo-1.0'",
"'-lpango-1.0'",
"-lharfbuzz",
"'-latk-1.0'",
"-lcairo-gobject",
"-lcairo",
"'-lgdk_pixbuf-2.0'",
"'-lgio-2.0'",
"'-lgobject-2.0'",
"'-lglib-2.0'",
"-lintl",
[...]
Related
I am getting the following errors after setting up C++ on VS Code and running starter code.
OS: MacOS Ventura 13.1 (Intel)
Editor: VS Code.
Compiler: clang++ (default)
#include errors detected. Please update your includePath. Squiggles are disabled for this translation unit
cannot open source file "tr1/cwchar" (dependency of "iostream")
Below are my config files (c_cpp_properties, tasks, launch)
c_cpp_properties.json
{
"env": {
"myDefaultIncludePath": ["${workspaceFolder}", "${workspaceFolder}/include"],
"myCompilerPath": "/usr/local/bin/clang++"
},
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**",
"/usr/local/Cellar/gcc/11.2.0_3/include/c++/11/tr1",
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1"
],
"defines": [],
"macFrameworkPath": [
"/System/Library/Frameworks"
],
"compilerPath": "/usr/bin/clang++",
"cStandard": "gnu17",
"cppStandard": "gnu++17",
"intelliSenseMode": "macos-gcc-x64"
}
],
"version": 4}
tasks.json
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "C/C++: clang++ build active file",
"command": "/usr/bin/clang++",
"args": [
"-std=c++17",
"-stdlib=libc++",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
]
}
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "C/C++: clang++ build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "lldb",
"preLaunchTask": "C/C++: clang++ build active file"
}
]
}
The c++ code builds and runs. The error however persists. Anything regarding C++ installation might help.
PS: This is my first time setting up C++.
problem
I'm using vscode to remotely connect to linux server. When I try to debug on my cpp program, which includes these header files under one directory
#include "codec_def.h"
#include "codec_app_def.h"
#include "codec_api.h"
it always come up with an include error:
codec_def.h: No such file or directory
the same error shows up to codec_app_def.h when I comment out the first header file codec_def.h
I have tried
I googled on this problem and find one solution-include path to the c_cpp_properties.json file.
Here is the path screenshot,
path screenshot
and my newly updated c_cpp_properties.json file is like this, I added ${workspaceFolder}/codec/api/svc/ to includePath,
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/codec/api/svc/",
"/usr/include",
"${workspaceFolder}/**",
"${workspaceFolder}/codec/decoder/core/inc",
"/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7",
"/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/x86_64-redhat-linux",
"/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/backward",
"/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/include",
"/usr/local/include",
"/opt/rh/devtoolset-7/root/usr/include"
],
"defines": [],
"compilerPath": "/opt/rh/devtoolset-7/root/usr/bin/g++",
"cStandard": "c11",
"cppStandard": "gnu++14",
"intelliSenseMode": "linux-gcc-x64"
}
],
"version": 4
}
but I still get the same error and I can't figure out why and how to solve it.
in case of other problems, here are tasks.json file
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++ build active file",
"command": "/opt/rh/devtoolset-7/root/usr/bin/g++",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "/opt/rh/devtoolset-7/root/usr/bin"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "compiler: /opt/rh/devtoolset-7/root/usr/bin/g++"
}
],
"version": "2.0.0"
}
and 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": "(gdb) run and debug",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [
"/root/compress/losslessh264/tibby.264",
"/fordebug/b.pip"
],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "set up pretty printing",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "set desassembly flavor Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++ build active file",
"miDebuggerPath": "/usr/bin/gdb"
},
{
"type": "bashdb",
"request": "launch",
"name": "Bash-Debug (select script from list of sh files)",
"cwd": "${workspaceFolder}",
"program": "${command:SelectScriptName}",
"args": []
},
{
"type": "bashdb",
"request": "launch",
"name": "Bash-Debug (simplest configuration)",
"program": "${file}"
}
]
}
I have been stuck in this problems for days, it will be a great help if you know the answer, thank you in advance :)
When I press F5 key to run a C++ program on Visual Studio Code, I get the message
"Unable to start debugging. Unable to establish a connection to GDB. Debug output may contain more information."
I use g++.exe and MinGW for compiling.
Until an hour ago, the debugging with F5 key was done properly, and I've never touched launch.json. Could you tell me what is wrong?
Below is the 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": "g++.exe - アクティブ ファイルのビルドとデバッグ",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"console": "externalTerminal",
"MIMode": "gdb",
"miDebuggerPath": "C:\\mingw-w64\\x86_64-8.1.0-win32-seh-rt_v6-rev0\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "gdb の再フォーマットを有効にする",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++.exe アクティブなファイルのビルド"
}
]
}
Below is the tasks.json
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++.exe アクティブなファイルのビルド",
"command": "C:\\mingw-w64\\x86_64-8.1.0-win32-seh-rt_v6-rev0\\mingw64\\bin\\g++.exe",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": "build",
"detail": "コンパイラ: C:\\mingw-w64\\x86_64-8.1.0-win32-seh-rt_v6-rev0\\mingw64\\bin\\g++.exe"
},
{
"type": "cppbuild",
"label": "C/C++: g++.exe アクティブなファイルのビルド ver(1)",
"command": "C:\\mingw-w64\\x86_64-8.1.0-win32-seh-rt_v6-rev0\\mingw64\\bin\\g++.exe",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "デバッガーによって生成されたタスク。"
}
]
}
Below is the c_cpp_properties.json
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"${vcpkgRoot}/x86-windows-static/include",
"C:\\Users\\SonicTheHedgehog\\Desktop\\include"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.18362.0",
"compilerPath": "C:\\mingw-w64\\x86_64-8.1.0-win32-seh-rt_v6-rev0\\mingw64\\bin\\g++.exe",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-x64"
}
],
"version": 4
}
Addition:
I found an error message on launch.json
Property console is not allowed
and console is marked with wavy line.
Check out this link: https://github.com/microsoft/vscode-cpptools/issues/2889
There is some problem with PowerShell being run as in internal console (running within VSCode).
I made the following change in launch.json:
before:
"environment": [],
"externalConsole": **false**,
"MIMode": "gdb",
after:
"environment": [],
"externalConsole": **true**,
"MIMode": "gdb",
Now, I see the output of the program in cmd.exe outside VSCode. But, the debugger runs fine inside VSCode.
I recommend using a different compiler-based extension such as code runner etc, sometimes, extensions are compatibility issues in visual studio code. I faced the same problem when I started to use visual studio code.
I've been reading at almost every question related to include paths in vscode but I just can't solve my issue.
My project folder's custom libraries is in the following path
"/home/gdl/DSS2-DEV/infra"
The infra folder is structured as such:
>Infra
>Include
... some header files
>lib1
>Include
... header files
>src
... cpp files
>lib2
>Include
... header files
>src
... cpp files
So, in order to use any of these libraries, I set up the vscode environment
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "g++ - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [ {"name": "LD_LIBRARY_PATH", "value": "/usr/local/lib:$LD_LIBRARY_PATH" }],
"externalConsole": false,
"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"
}
]
}
tasks.json
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "C/C++: g++ build active file",
"command": "/usr/bin/g++",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}",
"-I",
"/home/gdl/DSS2-DEV/infra"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": "build"
}
]
}
c_cpp_properties.json
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/home/gdl/DSS2-DEV/infra"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c11",
"cppStandard": "c++14",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}
and yet, not a single library can be included:
cpp file
#include <cstdio>
#include <libadm.h>
int main()
{
return 0;
}
Executing task: /usr/bin/g++ -g /home/gdl/DSS2-DEV/infra/parser.cpp -o /home/gdl/DSS2-DEV/infra/parser -I /home/gdl/DSS2-DEV/infra <
/home/gdl/DSS2-DEV/infra/parser.cpp:2:20: fatal error: libadm.h: No such file or directory
#include <libadm.h>
I tried using slashes but it doesn't change a thing. What drives me crazy is that if I CTRL-click the library it actually shows me the header file of that library, meaning that vscode is correctly linking files togheter.
I also tried using quotes instead of brackets for the include but nothing works
I got some problem with using OpenCV on VS Code for C++.
I can compile the C code but when I include the OpenCV libraries, it always displays the following error message:
fatal error: opencv2/opencv.hpp: No such file or directory
My VS Code version is 1.41.1 (user setup).
I downloaded OpenCV 3.4.1 from this site:
https://github.com/huihut/OpenCV-MinGW-Build
The environment path in my computer is:
The path to OpenCV is D://opencv//build.
Here are my configurations for using OpenCV in VS Code:
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:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\bin\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "啟用 gdb 的美化顯示",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "g++.exe build active file"
}
]
}
task.json
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "g++",
"args": [
"-g",
"${file}",
"-o",
"${fileBasenameNoExtension}.exe",
"-I",
"D:\\opencv\\build\\include",
"-L",
"D:\\opencv\\build\\x64\\mingw\\bin",
"-l",
"libopencv_calib3d341",
"-llibopencv_core341",
"-llibopencv_dnn341",
"-llibopencv_features2d341",
"-llibopencv_flann341",
"-llibopencv_highgui341",
"-llibopencv_imgcodecs341",
"-llibopencv_imgproc341",
"-llibopencv_ml341",
"-llibopencv_objdetect341",
"-llibopencv_photo341",
"-llibopencv_shape341",
"-llibopencv_stitching341",
"-llibopencv_superres341",
"-llibopencv_video341",
"-llibopencv_videoio341",
"-llibopencv_videostab341"
],
"group": {
"kind": "build",
"isDefault": true
}
},
{
"type": "shell",
"label": "g++.exe build active file",
"command": "C:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin\\g++.exe",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "C:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin"
},
"problemMatcher": [
"$gcc"
],
"group": "build"
}
]
}
c_cpp_properties.json
{
"configurations": [
{
"name": "Win32",
"compilerPath": "C:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin\\x86_64-w64-mingw32-g++.exe",
"includePath": [
"${workspaceRoot}",
"C:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\include",
"C:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\8.1.0\\include",
"C:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\8.1.0\\include\\c++",
"D:\\opencv\\build\\include"
],
"defines": [
"_DEBUG",
"UNICODE",
"__GNUC__=5",
"__cdecl=__attribute__((__cdecl__))"
],
"intelliSenseMode": "clang-x64",
"browse": {
"path": [
"${workspaceRoot}",
"C:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\include",
"C:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\8.1.0\\include",
"C:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\8.1.0\\include\\c++",
"D:\\opencv\\build\\include"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
}
],
"version": 4
}
is "D:\opencv\build\include" your opencv installed path? you can cd to that directory and check if "opencv2/opencv.hpp" exists. The point is to find where "opencv2/opencv.hpp" locates in your system and put that path to the c_cpp_properties.json "includePath".