Get gcc to Work in Any Folder

The best way to get the gcc command to work in any folder in Windowsis to place its bin folder (where gcc lives) onto the search path. This can be a complex operation, so pay attention!

First you need to know where the bin folder is located, the bin folder's path. This is the hardest part because most folks began using computers with Windows, which doesn't emphasize paths as much as command prompt OSs do.

If you've installed MinGW according to its wont, then the path to bin may look like this:


(This can be seen in the Address Bar if you open the bin folder in a window.)

Or if you installed MinGW in the Program Files folder, the path may be:

C:\Program Files\MinGW\bin

Or even:

C:\Program Files (x86)\MinGW\bin

Or maybe you're using another compiler and the path is something like:



C:\Program Files\OtherGCC\bin

Whatever! Write down or memorize or copy that path. It's important. It must be accurate!

Second, you need to modify the path environment variable in Windows so that Windows knows where to look for GCC and its companion commands. To do that, follow these steps:

1. Open the Control Panel's System icon; the keyboard shortcut is Win+Break (my favorite keyboard shortcut). Win+Break is also the Win+Pause key, should your keyboard not sport the Break key.

2. If you're using Windows XP, skip to step 5.

3. In Windows 8, Windows 7, and Windows Vista, choose Advanced System Settings on the left side of the System window.

4. In Windows Vista, click the Continue button or type in the Administrator's password to get by the UAC warning.

5. If necessary, click the Advanced tab in the System Properties dialog box.

6. Click the Environment Variables button.

7. Choose the Path variable from the bottom part of the dialog box, shown above.

8. Click the Edit button.

9. Click in the Variable value text box.

10. Press the End key on your keyboard so that you may add text to the end of path.

11. Type a semicolon, ;

12. Type the path to the BIN folder, as in:


13. Double-check! The path command contains no spaces.

14. Click OK to close the Edit System Variable box.

15. Click OK to close the Environment variables box.

16. Click OK to close the System Properties window.

The changes take affect with the next command prompt window you open. If you were successful, then you can run the gcc command in any folder/directory at the command prompt.

To confirm that gcc is working, type the following command at the prompt:

gcc --version

If you see the gcc version number and other information displayed, then you're ready to go.

Any questions? E-mail me:

dan at c-for-dummies dot com