Notepad++, NppExec, CreateProcess() failed with error code 2, Windows 8.1

▼魔方 西西 提交于 2019-12-13 16:36:41

问题


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.



来源:https://stackoverflow.com/questions/21523226/notepad-nppexec-createprocess-failed-with-error-code-2-windows-8-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!