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

17,242

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.

Share:
17,242
Edwin
Author by

Edwin

Updated on June 04, 2022

Comments

  • Edwin
    Edwin almost 2 years

    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.

  • Edwin
    Edwin about 10 years
    I did change perl.exe to Compile.exe, which initially thought it's only a prefix of a new filename for every compiled code.
  • Marco A.
    Marco A. about 10 years
    What compiler are you planning to use? MSVC2010/2012 ?
  • Edwin
    Edwin about 10 years
    I did change perl.exe to Compile.exe, which initially thought it's only a prefix of a new filename for every compiled code. I have used Bloodshed dev-cpp in my older laptop, however, not in this brand new laptop I'm working on. The older laptop works with both installed. Problem is its has been more than a year ago. Hence, the need to repeat the installation and config on my new laptop.. My question is does Bloodshed dev-cpp have to exist (as in pre-installed) in order for Notepad++ to be a C++ compiler? If that's the case, I will install to necessitate the compile function. Thank you.
  • Marco A.
    Marco A. about 10 years
    Notepad++ ISN'T a compiler, it just asks a compiler to compile your program. And yes, you must have a compiler installed (dev-cpp, visual studio ..) to compile stuff via notepad++. Notepad++ just helps you write stuff, doesn't compile anything by itself.
  • Edwin
    Edwin about 10 years
    Hi David, I got your point clear! Thanks for you patience! Trying out MinGW to minimize IDE.
  • Marco A.
    Marco A. about 10 years
    MinGW has a port of the gcc compiler, that will surely work to compile your program if correctly configured.
  • Edwin
    Edwin about 10 years
    I have finally made it. Took quite a bit of searching to get the right script F6 execute. And also, at the initial stage there is a missing file. However, got over it by adding the Path in windows system config. Here is an extract of the script from somewhere www. Thank you! cmd /c C:\MinGW\bin\g++.exe -ansi -pedantic -Wall -W -Wconversion -Wshadow -Wcast-qual -Wwrite-strings $(FILE_NAME) -o $(NAME_PART).exe & IF ERRORLEVEL 1 (echo. && echo Syntax errors were found during compiling.) ELSE ($(NAME_PART).exe)