79753451

Date: 2025-09-02 11:46:09
Score: 0.5
Natty:
Report link

Thanks to the commenters (especially Ted Lyngmo, Ali Nazzal, and jabaa) for their diagnostic help. Their suggestions helped me isolate the problem and find the final solution.

The Root Cause

The core issue was that the MinGW compiler's directory (C:\msys64\mingw64\bin) was not added to the Windows PATH environment variable.

This created a confusing situation with the following symptoms:

  1. The g++ command worked perfectly in the VS Code integrated terminal (which likely adds the compiler to its own PATH for the session).

  2. The command failed with missing DLL errors when run in a standalone Windows Command Prompt (which uses the system's global PATH).

  3. The command failed silently with exit code 1 when run by the VS Code task runner, as the task runner was also using the system's global PATH and couldn't find the necessary DLLs for g++.exe.

The Solution

The problem was solved permanently by adding the MinGW bin directory to the Windows system PATH variable:

  1. Searched for and opened "Edit the system environment variables" in the Windows Start Menu.

  2. Clicked on the "Environment Variables..." button.

  3. Under "System variables", selected the Path variable and clicked "Edit...".

  4. Clicked "New" and added the following path:

    C:\msys64\mingw64\bin
    
    
  5. Clicked "OK" on all windows to save the changes and rebooted the computer.

After rebooting, the VS Code build task now works correctly.

Reasons:
  • Blacklisted phrase (0.5): Thanks
  • Long answer (-1):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: 안영민