I'm learning C++ for the first time (im using microsoft visual studio code) and i'm trying to run my code based on the video im watching. I have exactly what he has in the video but i have an error;
PS C:\Users\Baseb> g++ cpplearning.cpp
g++ : The term 'g++' is not recognized as the name of a cmdlet, function, script file,
or operable program. Check the spelling of the name, or if a path was included, verify
At line:1 char:1
g++ cpplearning.cpp
+ CategoryInfo : ObjectNotFound: (g++:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException .
I have downloaded minGW and the path i was using is; C:\MinGW\bin . Do you know why I am getting this error code? I typed G++ --version and it shows I do have G++ installed on my computer.
Thank You
If you run g++ from a terminal and it is a Windows terminal (cmd or other), you have to include the g++ binary path in the Windows PATH environment variable.
If you run the compiler from VS then follow the link from #Eljay comment.
Related
I'm simply trying to print out Hello world. I installed minGW, but the code simply won't work. It gives a "can't find path" error, but I have completed everything to download minGW, and the command prompt shows nothing wrong when I typed cd desktop. Additionally, I enabled theVSC to run on the terminal, but it won't work.
I am expecting the code to print Hello world, but this is what it prints out:
cd : Cannot find path 'C:\MinGW\binc\Users\Harold\Desktop\waffle\' because it does not exist.
At line:1 char:1
+ cd "C:/MinGW/binc/Users/Harold/Desktop/waffle/" ; if ($?) { g++ test. ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\MinGW\binc\U...Desktop\waffle\:String) [Set-Location], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SetLocationCommand
In my folder are these files:
hello.cpp hello.exe hello.ilk hello.pdb
When I try to execute the .exe file within a terminal in VS Code I receive this:
C:\Users\User\Documents\VS_Code> hello.exe
hello.exe : The term 'hello.exe' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the
path is correct and try again.
At line:1 char:1
+ hello.exe
+ ~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (hello.exe:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Suggestion [3,General]: The command hello.exe was not found, but does exist in the current location. Windows PowerShell does not load commands from the current location by default. If you trust this command, instead type: ".\hello.exe". See "get-help about_Command_Precedence" for more details.
When I'm running it from the developer prompter from Visual Studio it works.
I think your issue can be solved by just looking at the error suggestion. It says to use .\hello.exe .
Hope this helps :)
I'm trying to set c/c++ environment in my visual studio code. I have installed the mingw and set the environmental variable of the bin folder. However upon running a code in vs code, it shows the following error:
g++ : The term 'g++' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the
name, or if a path was included, verify that the path is correct and
try again. At line:1 char:40
cd "e:\vsCodes\Cpp Codes" ; if ($?) { g++ threen1.cpp -o threen1 } ; ...
CategoryInfo : ObjectNotFound: (g++:String) [], CommandNotFound Exception
FullyQualifiedErrorId : CommandNotFoundException
But command prompt shows the following message when I enter g++ --version:
g++ (tdm64-1) 10.3.0 Copyright (C) 2020 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.
I have tried solving the issue following the answers in this thread.
You are using powershell terminal, If you dont know what powershell is or you dont need powershell, I recommend you to run Command prompt terminal (cmd). It's available in terminal menu here:
In powershell you can verify that g++ in PATH running this command echo $env:path, it's powershell equivalent of echo %PATH%
I feel like this is a very trivial question, I cannot figure out for the life of me what is going on with my VScode.
that the path is correct and try again.
At line:1 char:1
+ make
+ ~~~~
+ CategoryInfo : ObjectNotFound: (make:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Suggestion [3,General]: The command make was not found, but does exist in the current location. Windows PowerShell does not load commands from the current location by default. If you trust this command, instead type: ".\make". See "get-help about_Command_Precedence" for more details.
I am just trying to compile two files together to make them work. They compile and execute seperately, but when I use the 'make' command, in the terminal within VS, it delivers this error.
I believe that my makefile is setup correctly, literally following my professors video on how to do it and it's working properly.
Any pointers??
As the message says: Make command is not found!
Make sure your make command does exist by simply typing make and hitting enter.
if it does not exist install both: build-essentials and make using pip/conda/npm/npx
These are the main rules to make the target work!
I downloaded the 64 version for windows of sublime text, but whenever I try to compile a C++ file using the system build I get the following message:
"The program or feature "\??\C:\Users\Windows\system.exe" cannot start or run due to incompatibility with 64-bit versions of Windows. Please contact the software vendor to ask if a 64-bit Windows compatible version is available."
For the build system I used this->
{
"cmd" : ["C:\\cygwin\\bin\\g++ $file -o ${file_base_name}"],
"selector" : "source.cpp",
"shell" : true,
"working_dir" : "$file_path"
}
I've already modify the PATH system variable...
Any help?
"cmd" : ["C:\cygwin\bin\g++ $file -o ${file_base_name}"]
I think you can append ".exe" after "g++".