Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wermelinger-stefan opened this issue Apr 16, 2025 · 5 comments
Labels
debugger more info needed The issue report is not actionable in its current state question

Comments

@wermelinger-stefan
Copy link

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'

@ntrogh ntrogh transferred this issue from microsoft/vscode-docs Apr 16, 2025
@bobbrow
Copy link
Member

bobbrow commented Apr 23, 2025

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?

@bobbrow bobbrow added question debugger more info needed The issue report is not actionable in its current state labels Apr 23, 2025
@wermelinger-stefan
Copy link
Author

Hi @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

@bobbrow
Copy link
Member

bobbrow commented Apr 24, 2025

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

@wermelinger-stefan
Copy link
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..

@bobbrow
Copy link
Member

bobbrow commented Apr 24, 2025

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
Labels
debugger more info needed The issue report is not actionable in its current state question
Projects
None yet
Development

No branches or pull requests

2 participants