How to Add the Mingw Bin Directory to My System Path

How do I add the MinGW bin directory to my system path?

To change the path on Windows XP, follow these instructions, and then add the directory where you install MinGW plus bin. Example: if you install MinGW in C:\ then you have to add C:\mingw\bin to your path

Just for completeness here are the steps shown on the link:

  1. From the desktop, right-click My Computer and click Properties.
  2. In the System Properties window, click on the Advanced tab.
  3. In the Advanced section, click the Environment Variables button.
  4. Finally, in the Environment Variables window, highlight the Path variable in the Systems Variable section and click the Edit button. Add or modify the path lines with the paths you wish the computer to access. Each different directory is separated with a semicolon as shown below.

    C:\Program Files;C:\Winnt;C:\Winnt\System32;c:\mingw\bin

How do I set path to respective bin of the mingw directory

Ok, I've skimmed that tutorial video and YouTube comment section. Basically I think it's a poor tutorial, as it doesn't explain the basics, and that's why you're getting tripped up. My first recommendation is to save yourself some trouble and follow the VSCode Getting Started with C++ Tutorial instead.

Not only is the official tutorial easier to understand, it will guide you toward using the Microsoft C++ extension that almost everyone uses (and can help you with), rather than the comparatively obscure Clang-based C++ extension.

But that's not answer to your actual question. You asked:

... the instructions for installing clang say to "set path to respective bin of the mingw directory" without showing me how.

What does this mean and how do I do that?

I'm not sure! It's sort of nonsensical. But I think what is meant is:

  1. Install mingw GCC and put its bin directory on the PATH.
  2. Install LLVM+Clang and put its bin directory on the PATH.
  3. Start VSCode from a shell where both are on the PATH.
  4. Then proceed with the linked tutorial.

You say you already have mingw GCC on your path, but let's check that. At the command prompt (I assume you are using the default Windows cmd.exe shell), run:

> gcc --version
gcc (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 5.4.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

If you don't see output like that, then something is wrong. Make sure the bin directory of mingw GCC, which contains gcc.exe, is on your PATH.

Next, Clang. Clang is part of LLVM. Wherever you installed LLVM, there should be a bin directory inside it containing clang.exe. Add that to your PATH. In my case, I installed LLVM into d:\opt\llvm-8.0.1, so I would run:

> set PATH=%PATH%;d:\opt\llvm-8.0.1\bin

Then check that it is working:

> clang --version
clang version 8.0.1 (tags/RELEASE_801/final)
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: D:\opt\llvm-8.0.1\bin

Once both gcc --version and clang --version respond similarly to what I have shown, you're ready to start VSCode:

> code

and from there, the tutorial's instructions should work.

gcc is not recognized even after setting PATH variable. What is left?

Have you checked your path in the windows GUI? Search in windows (Windows+S) for "environment variables" and click "edit the system environment variables." Then click environment variables (the button). Add the path to your MinGW/bin (binaries) folder to your system PATH variable!! (not user). Try this.

If you have, you will need to close your cmd window and open a new one, as well as possibly needing to restart/sign out and sign in.

Also make sure you installed the gcc part of MinGW and not just g++ compiler (I can't remember the install options right now).

mingw path in environment variable on windows10

Can you check it really exists there by running:

DIR C:\Qt\5.15.0\mingw81_64\bin\gcc.exe

If it's not there then try

DIR C:\Qt\5.15.0\mingw81_64\bin\*gcc.exe

to see if you have something like x86_64-w64-mingw32-gcc.exe, which is what you should use then instead.

Unable to properly add Mingw-w64 to Path on Windows 8.1

Windows 10 shows the path entries as a list you can edit. That's where the "New" button comes into play. But that's just a convenience. Fundamentally, you are being instructed to append

C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin

to the list to get

C:\Users\eric\AppData\Local\Mu\bin;C:\Users\eric\introcs\j3d\bin;C:\Users\eric\introcs\bin;C:\Users\eric\introcs\java\bin;C:\Users\eric\AppData\Local\GitHubDesktop\bin;C:\Users\eric\AppData\Local\Programs\Microsoft VS Code\bin;%USERPROFILE%\.dotnet\tools;C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin



Related Topics



Leave a reply



Submit