0

I've tried using Notepad++ to code c++ and followed a few tutorials on youtube, here's what I did:

-Installed gcc/g++ compiler using mingw64

-Installed NppExec plugin on N++

-Typed in the following compilier script and saved as C++:

NPP_SAVE cd
$(CURRENT_DIRECTORY)
g++ $(FILE_NAME)
cmd /c $(CURRENT_DIRECTORY)\program.exe

Anyways whenever compiling a program, for example a simple program

#include <iostream>
using namespace std;
int main(){
    cout << "Online\n";
    system("pause"); //So that cmd doesn't disappear immeadiately on running.
    return 0;
}

The console displays the following warning:
"C:\Users\pc\Desktop\Courses\Projects\C\program.exe' is not recognized as an internal or external command, operable program or batch file."
My question is,
When I run the program on cmd, it runs perfectly but the error displayed during linking says that the folder does not exist in %PATH%
Any explanation?
Thank you!

Khaled
  • 1
  • 3
  • `g++ $(FILE_NAME)` doesn't specify an output filename. If you go look in that directory is there a `program.exe` file or is it named `a.exe`? – Retired Ninja Dec 17 '21 at 21:39
  • @RetiredNinja Checked directory, file is `a.exe` not `program.exe` Should I replace (FILE_NAME) with the current program name? – Khaled Dec 17 '21 at 21:44
  • you can add -o option to g++ command: __g++ filename.c -o filename__ –  Dec 17 '21 at 21:59
  • You probably want something like `g++ $(FILE_NAME) -o $(NAME_PART)`. If that creates `program` instead of `program.exe` then `$(NAME_PART).exe` may work better. – Retired Ninja Dec 17 '21 at 22:09

1 Answers1

0

Ok so, what I basically did was change the script,

cmd /c $(CURRENT_DIRECTORY)\program.exe

To be later

cmd /c $(CURRENT_DIRECTORY)\a.exe

the console worked fine and even received input

Here is a link to a similar problem:

How to compile/execute C++ code from within Notepad++

Khaled
  • 1
  • 3