Run C++ within notepad++
-
You don’t provide any arguments to g++.exe, the command line even lacks the path to your source file. How should the compiler know what to do?
Go figure out the required compiler options for your project and read thoroughly the documentation of NppExec, there you can find all information needed.
-
kindly help me out. am trying but can’t figure it out
-
@kenn_ug said in Run C++ within notepad++:
kindly help me out. am trying but can’t figure it out
How would you do it from the command-line, without Notepad++? Ie, how would you compile the program if you used some other text editor for the source code, or had just downloaded it?
This is not a compiler forum, or a programming forum. If you tell us how you would compile and run the program without Notepad++, we can help you translate that into how to do it inside Notepad++. But without that, you’re asking us why you cannot bake your cookies.
-
@kenn_ug said in Run C++ within notepad++:
npp_save
cd $(CURRENT_DIRECTORY)
C:\MinGW\bin\g++
cmd /c “$(CURRENT_DIRECTORY) \a.exe”Seems like you may just be missing the file to compile:
npp_save cd $(CURRENT_DIRECTORY) C:\MinGW\bin\g++ "$(FULL_CURRENT_PATH)" cmd /c “$(CURRENT_DIRECTORY) \a.exe”
-
@kenn_ug you can use this
npp_save
cd $(CURRENT_DIRECTORY)
C:\MinGW\bin\g++ “$(FULL_CURRENT_PATH)” -g -o “$(name_part)”
cmd /c $(name_part) -
g++: error: no such file or directory
‘new’ is not recognized as an internal or external command, operable program or batch file.
Exit code 1 -
you have to give the file a name and save it somewhere valid.
-
where is somewhere valid?
-
where is somewhere valid?
Onto your filesystem (HDD/SSD, like the c: drive or d: drive, or onto a USB stick, or wherever).
My point was that the g++ error message seemed to say that it couldn’t find the file
new
. That tells me two things:First, because it says
new
, I am assuming that it’s actuallynew 1
or similar, which is what Notepad++ calls tabs that haven’t ever been saved, anywhere. You have to save the file (presumably tosomething.cpp
or similar) before you can run it through a compiler.Second, because the error message says
new
rather thannew 1
, I am assuming you don’t actually have the script(s) mentioned above, because you probably don’t have the quotes around the name variables like @Michael-Vincent and @mashrafi-dipto showed above.So make sure you save the file, and give it a meaningful name. Then show us the NppExec script that you are actually running – when you paste it into the forum, make sure to highlight the whole script and hit the
</>
button, so that it will be surrounded in```
characters on a line before and after your script in the edit window, and the PREVIEW window will show it in a black box, like @Michael-Vincent’s example above
-
#include namespace std;
int main()
(
cout << “Welcome to GFG”;return 0;
}
This file is saved in my Documents Folder with the .cpp extension but when I hit the run button a window opens and tells me to choose “The Program to Run” with a run, save or cancel option instead of just running the program.
-
This discussion was relying on the fact that everyone involved had the NppExec plugin installed. Everything that has been said in this discussion assumed that as a given.
I think before asking any more questions, you need to read and understand our FAQ on “how do I use Notepad++ to compile my source code”.