0

I'm trying to set up a OpenGL environment in vs code, I'm using MinGW64 with msys for compilation and package management, I wrote a tasks and launch json files for generating builds, but when I run the build that was generated I get an error stating "unable to establish connection to GDB" and my app aborts.

this is my launch.json:


    "version": "0.2.0",

    "configurations": 
    [
        {
            "name": "Lauch OpenGL App",
            "type": "cppdbg",

            "request": "launch",
            "preLaunchTask": "Build OpenGL App",
            
            "cwd": "${workspaceRoot}",
            "program": "${workspaceRoot}\\Build\\app",

            "stopAtEntry": false,
            "externalConsole": true,

            "MIMode": "gdb",
            "miDebuggerPath": "C:\\msys64\\mingw64\\bin\\gdb.exe",

            "setupCommands": 
            [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

This is my tasks.json:

{
    "tasks": 
    [
        {
            "label": "Compile source code",

            "type": "shell",
            "command": "C:\\msys64\\mingw64\\bin\\g++.exe",

            "args":
            [
                "-c",
                "main.cpp",
                "-o",
                "Build\\Temp\\main.o"
            ]
        },
        {
            "label": "Link Libraries",

            "type": "shell",
            "command": "C:\\msys64\\mingw64\\bin\\g++.exe",

            "args": 
            [
                "-o",
                "Build\\app", 
                "Build\\Temp\\main.o",
                "-L.",
                "-lglfw3",
                "-lopengl32",
                "-lgdi32"
            ]
        },
        {
            "label": "Cleanup",

            "type": "shell",
            "command": "Remove-Item",

            "args":
            [
                "Build\\Temp\\*.*"
            ]
        },
        {
            "label": "Build OpenGL App",
            "dependsOrder": "sequence",
            "dependsOn": ["Compile source code", "Link Libraries", "Cleanup"]
        }
    ],
    "version": "2.0.0"
}

When I run my build tasks everything works until the moment the app launches then the following error is shown:

App run error message

And this is printed to the console:

Console error message

niv shalom
  • 93
  • 8
  • 1
    Google 0xC000007B. Related: [https://stackoverflow.com/questions/10492037/the-application-was-unable-to-start-correctly-0xc000007b](https://stackoverflow.com/questions/10492037/the-application-was-unable-to-start-correctly-0xc000007b) – drescherjm Oct 06 '22 at 16:37
  • Maybe your problem is you a second MinGW bin in a folder of your `PATH` environment variable and its 32 bit causing x64 gdb to attempt to load a 32 bit dll as a dependency. – drescherjm Oct 06 '22 at 16:39
  • My path variable is pointing to the MinGW64 bin folder, and all the dll's im linking should work with 64 bit – niv shalom Oct 06 '22 at 16:48
  • Are you sure you don't have more than 1 version of MinGW installed? – drescherjm Oct 06 '22 at 16:54
  • 1
    You may want to try to see if C:\\msys64\\mingw64\\bin\\gdb.exe works from a cmd.exe window – drescherjm Oct 06 '22 at 16:55
  • 1
    Worth pointing out that you're not creating a debug build. – sweenish Oct 06 '22 at 18:34
  • @sweenish maybe I am missing something but this shouldn't be a debug build, just a regular build, I had a previous version of these json files for mingw32 that did the same that I used to format this version – niv shalom Oct 07 '22 at 04:25
  • @drescherjm the gdb exe launches with a error – niv shalom Oct 07 '22 at 04:25
  • Maybe you have to reinstall msys2. Or perhaps try disabling your antivirus. – drescherjm Oct 07 '22 at 12:15
  • Typically, one attaches their debugger to a debug build so the debugger can function. – sweenish Oct 07 '22 at 17:09

1 Answers1

0

No clue what the problem was, but I ended up reinstalling everything (msys, mingw, g++, gdb etc....) and the issue was fixed

niv shalom
  • 93
  • 8