Skip to content

Using GCC with MinGW Tutorial from https://code.visualstudio.com/docs/cpp/config-mingw #13519

Open

Description

@wermelinger-stefan

Hallo

I tried to run the Totorial as on the Website.
I wonder if anyone can tell me what went wrong.

When i try to ran the "helloworld.cpp" it kind of does something but the predicted Output "Hello C++ ..." does not come out.
I get instead:
PS D:\VSCodeCTest\helloworld> & 'c:\Users\werme.vscode\extensions\ms-vscode.cpptools-1.24.5-win32-x64\debugAdapters\bin\WindowsDebugLauncher.exe' '--stdin=Microsoft-MIEngine-In-pwvtuybk.efh' '--stdout=Microsoft-MIEngine-Out-fxxwglkc.ecy' '--stderr=Microsoft-MIEngine-Error-i0j22iyb.xlm' '--pid=Microsoft-MIEngine-Pid-c0kdexmb.aht' '--dbgExe=C:\msys64\ucrt64\bin\gdb.exe' '--interpreter=mi'

Also the Debuger does not start. There i get in the debugconsole:
=thread-group-added,id="i1"
GNU gdb (GDB) 15.2
Copyright (C) 2024 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-w64-mingw32".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
https://www.gnu.org/software/gdb/bugs/.
Find the GDB manual and other documentation resources online at:
http://www.gnu.org/software/gdb/documentation/.

For help, type "help".
Type "apropos word" to search for commands related to "word".
Warning: Debuggee TargetArchitecture not detected, assuming x86_64.
=cmd-param-changed,param="pagination",value="off"
[New Thread 9748.0x4fe0]
[New Thread 9748.0xc58]
[New Thread 9748.0x708]
[Thread 9748.0xc58 exited with code 3221225785]
[Thread 9748.0x708 exited with code 3221225785]
[Thread 9748.0x4fe0 exited with code 3221225785]
ERROR: Unable to start debugging. Unexpected GDB output from command "-exec-run". During startup program exited with code 0xc0000139.
The program 'D:\VSCodeCTest\helloworld\helloworld.exe' has exited with code 0 (0x00000000).


Where the Terminal says:
PS D:\VSCodeCTest\helloworld> & 'c:\Users\werme.vscode\extensions\ms-vscode.cpptools-1.24.5-win32-x64\debugAdapters\bin\WindowsDebugLauncher.exe' '--stdin=Microsoft-MIEngine-In-rtvx0ij4.whs' '--stdout=Microsoft-MIEngine-Out-20o5sims.3o2' '--stderr=Microsoft-MIEngine-Error-r55slmkn.ma3' '--pid=Microsoft-MIEngine-Pid-an52j2dy.zxc' '--dbgExe=C:\msys64\ucrt64\bin\gdb.exe' '--interpreter=mi'

Activity

  1. bobbrow commented on Apr 23, 2025

    @bobbrow
    Contributor

    Hi wermelinger-stefan,

    I'm not sure exactly where it went wrong, but here are some possibilities:

    • Did you add C:\msys64\ucrt64\bin to the Path environment variable?
    • After adding it to the Path, did you close VS Code and reopen it (either by double clicking the icon, or from a new terminal/shell that has the updated environment)?
    • I have seen some rare cases where VS Code still doesn't pick up the environment variable change and it requires logging out and logging back in to Windows.

    If none of those ideas resolve the problem, can you share the contents of any tasks.json or launch.json files you find in the .vscode folder in your workspace?

  2. wermelinger-stefan commented on Apr 24, 2025

    @wermelinger-stefan
    Author

    Hi Bob Brown (@bobbrow)

    Thanks for those recommodations.
    I actually have shut down the entire system multiple times since.
    Path-variable is set to correct one.

    Image

    When i start the "run" i get the correct "C:\msys64\ucrt64\bin\g++.exe" to choose from.

    Image

    The tasks.json is as follow:
    Image
    There are no other files like launch.json in this folder.

    Image

    I tried also the same for a only C - Code.
    This compiles und runs perfect.

    Image

    However when i try to take another C++, similar Code i get a segmentation fault:
    Maybe that helps:

    Image

  3. bobbrow commented on Apr 24, 2025

    @bobbrow
    Contributor

    When you compile the C++ file into helloworld.exe, are you able to run it without the debugger? For example, open the Terminal window and run helloworld.exe without going through our debugger or the "play" button in the IDE.

    If that's not working, let's try compiling and running the file yourself in the Terminal and see if that works:

    1. g++ helloworld.cpp -o test.exe
    2. test.exe
  4. wermelinger-stefan commented on Apr 24, 2025

    @wermelinger-stefan
    Author
    1. Yes a can run a comiled C file as testc.exe thats OK.
    2. When i try to compile a .cpp file with actual c++ code in it.
      PS D:\VSCodeCTest\helloworld> g++ .\helloworld.cpp -o testcpp.exe
      collect2.exe: error: ld returned 116 exit status

    Image

    When i insert some c printf into a cpp file i can ran it with the debugger..

    Image

    I think there is something wrong with the c++ "solver" or however it is called, because as soon as i try to run c++ it doesn't do what its meant to..

  5. bobbrow commented on Apr 24, 2025

    @bobbrow
    Contributor

    Something may have gone wrong with your MinGW installation. I believe I have the same version as you and these commands work for me.

    Image

    Image

    I'm not an expert at troubleshooting issues with the toolset itself, so my best recommendation at this point is to try uninstalling and reinstalling the package. If that doesn't work, consider uninstalling all of Msys2 and retrying from the beginning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions