RonsJurisdiction
RonsJurisdiction

Reputation: 240

g++ is not recognized as an internal or external command Windows 10

Image of the folder and directoryFirst off I would like to say I've seen the previous questions on this site, I've tried every solution but none fit my use case or solves my problem.

I am having trouble with the g++ complier being recognized, I've included this path:

C:\Program Files (x86)\mingw-w64\i686-7.2.0-posix-dwarf-rt_v5-rev1\mingw32\bin\g++.exe

which is where the current version of mingw is located (recently downloaded). I've also tried other options like changing the path to gcc.exe, and just regular bin. Someone please provide a detailed solution to this problem.

Other things i have tried and looked at closely would be: http://stephencoakley.com/2015/01/21/guide-setting-up-a-simple-c-development-environment-on-windows

seeing as though I'm working through sublime text 3

Another thing Ive tried:

Ive tried to copy and paste the path into cmd and run it , but i find this error code:

C:\Users\Kxrk>C:\Program Files (x86)\mingw-w64\i686-7.2.0-posix-dwarf-rt_v5-rev1\mingw32\bin\g++.exe
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.

So seeing that, i tried another way , and that is to drag the file and drop it into cmd and get this :

  C:\Users\Kxrk>C:\Program Files (x86)\mingw-w64\i686-7.2.0-posix-dwarf-rt_v5-rev1\mingw32\bin\g++.exe
    g++.exe: fatal error no input files
    compilation terminated

when u drag and drop the file it has double quotes around it , so i tried editing the path to contain double quotes around it and the path automaticlly changes back after saving.

Upvotes: 1

Views: 18850

Answers (4)

user19535821
user19535821

Reputation:

Go to your command propmpt, type set path, it will show list of directories, copy them,

Now type set path=<data you copied> and then add a semicolon and possible directory to g++ usually C:\MinGW\bin

Upvotes: 0

RonsJurisdiction
RonsJurisdiction

Reputation: 240

This was very simple , it was one of those weird cases.

To solve my problem what i did was:

1: uninstall , the current version of the mingw compiler , because i felt as though the one i had was corrupt in a way.

2:Redownloaded it the compiler from the website http://www.mingw.org/

3: set up the new Environmental variable where i save it , witch was C:\MinGW\bin

  1. I had to install g++ from the command line(cmd ,command prompt) by using this command mingw-get install g++witch is located inside bin on default

  2. now i created one more directory in the environmental variables , C:\MinGW\bin\g++.exe

6.Now everything works , and is normal

Upvotes: 6

Barmak Shemirani
Barmak Shemirani

Reputation: 31619

You have to use quotation marks around the path so that is treated as a single path:

c:\>"c:\program files\path\g++.exe"

A better way is to set the environment variables. Open Environment variables windows (in Windows 10 you can type in "environment variables" in search box) or right click on "Computer" in desktop, open "Advanced System Settings" and find the button for "Environment variables"

Upvotes: 0

Sister Fister
Sister Fister

Reputation: 368

If you are trying to run the compiler from the command line then you have to put double quotes around the path, because the path contains two whitespaces (this is the reason for the first error).

The reason for second error is that you didn't specify which C++ program you want to compile. You have to append the filename of your C++ input file to your command:

C:\Users\Kxrk>"C:\Program Files (x86)\mingw-w64\i686-7.2.0-posix-dwarf-rt_v5-rev1\mingw32\bin\g++.exe" program.cpp

See Barmak Shemiranis answer if don't want to enter the full path all the time. After that you can just use this:

C:\Users\Kxrk>g++ program.cpp

Upvotes: 0

Related Questions