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:
- From the desktop, right-click My Computer and click Properties.
- In the System Properties window, click on the Advanced tab.
- In the Advanced section, click the Environment Variables button.
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:
- Install mingw GCC and put its
bin
directory on thePATH
. - Install LLVM+Clang and put its
bin
directory on thePATH
. - Start VSCode from a shell where both are on the
PATH
. - 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
What C++ Library Should I Use to Implement a Http Client
Error: C2228: Left of '' Must Have Class/Struct/Union
Should I Use Printf in My C++ Code
The Difference Between Delete and Delete[] in C++
How to Calculate Perspective Transform for Opencv from Rotation Angles
Is the Default Move Constructor Defined as Noexcept
Calculating Factorial Using Template Meta-Programming
Why Should I Initialize Member Variables in the Order They'Re Declared In
Error: Passing 'Const …' as 'This' Argument of '…' Discards Qualifiers
When Is It Safe to Call This-> in Constructor and Destructor
Calling Derived Class Function from Base Class
Where Does One Get the "Sys/Socket.H" Header/Source File
C++: Pointer to Monomorphic Version of Virtual Member Function
How to Add Wtl and Atl to Visual Studio C++ Express 2008
How to Copy One Map into Another Using Std::Copy
How to Tame the Windows Headers (Useful Defines)
Why Do Linked Lists Use Pointers Instead of Storing Nodes Inside of Nodes