Notepad++, NppExec, CreateProcess() failed with er

2019-07-17 23:36发布

问题:

I'm new to Notepad++ and C++ programming language. I couldn't figure out what has gone wrong, albeit, it might look simple to resolved to many. Tried to search for solution, but to no avail. While trying to config the application for C++ compiler on Windows 8.1, I encountered the below message.

NPP_SAVE: C:\Users\rolle_000\Desktop\HelloWorld.cpp
CD: C:\Users\rolle_000\Desktop
Current directory: C:\Users\rolle_000\Desktop
Compiled.exe -c -w "HelloWorld.cpp"
CreateProcess() failed with error code 2:
The system cannot find the file specified.

================ READY ================

The C++ basic code, simple to testing only.

// A hello world program in C++

#include<iostream>
using namespace std;

int main()
{
    cout << "Hello World!";
    return 0;
}

The NppExec script taken from

How to compile and run C files from within Notepad++ using NppExec plugin? Below embedded mine, script hasn't change much.

NPP_SAVE
CD $(CURRENT_DIRECTORY)
Compiled.exe -c -w "$(FILE_NAME)"

Pls advice, thank you.

回答1:

You're trying to execute a

Compiled.exe

which indeed doesn't exist (yet) instead of the

perl.exe -c -w "$(FILE_NAME)"

perl.exe is the perl's executable and is supposed to be used with a perl's program. To compile C++ programs you will need to use a C++ compiler.

Now: this all boils down to the compiler you want to use... which one are you going to use? MSVC (Microsoft Visual Studio) ? Bloodshed dev-cpp?

Example: if you have MSVC2010 installed you might use:

  1. Execute Start->All Programs->Microsoft Visual Studio 2010->Visual Studio Tools->Visual Studio Command Prompt (2010)

  2. Digit cl (yourFileName).cpp

  3. You're done, yourFileName.exe should now exist

So the above would have to be rewritten as:

cl.exe "$(FILE_NAME)"

after making sure the path to cl.exe is correctly available.