Aman Chouhan
Aman Chouhan

Reputation: 1

How to Run gtk+ of cpp applicatiion In vscode?

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.....

Upvotes: 0

Views: 480

Answers (1)

Steffen
Steffen

Reputation: 36

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",
[...]

Upvotes: 1

Related Questions