Trouble Setting Up NppExec to Learn C++



  • I use Notepad++ for all my text editing needs, I thought it would be nice to use it as I try to learn C++ with my son who is interested in learning to program for robotics. I have installed MinGW on Win10 and the C:MinGW\bin folder has been added to the system path. I searched the forum and got the following code to put into NppExec to run the c++ compiler and then run the compiled file.
    npp_save
    cd "$(CURRENT_DIRECTORY)"
    g++ "$(FILE_NAME)" -o "$(NAME_PART)"
    cmd /c "$(NAME_PART)"

    Unfortunately, I get the following when I run the script in NppExec:
    NPP_SAVE: C:\Users\CorrectPathtoCurrentDirectory\CPP-Projects\hello.cpp
    CD: C:\Users\CorrectPathtoCurrentDirectory\CPP-Projects
    Current directory: C:\Users\CorrectPathtoCurrentDirectory\CPP-Projects
    g++ "hello.cpp" -o "hello"
    CreateProcess() failed with error code 2:
    The system cannot find the file specified.

    cmd /c "hello"
    Process started >>>
    'hello' is not recognized as an internal or external command,
    operable program or batch file.
    <<< Process finished. (Exit code 1)
    ================ READY ================

    I have tested that g++.exe works by opening a powershell in that directory, and running the following command:
    g++.exe .\hello.cpp -o hello.exe
    This compiled the text file into an executable that also worked in powershell. I would appreciate any help in being able to call g++ from within Notepad++ and see the output in the Console of NppExec. Thanks.



  • @Steve-Daley175

    Try this:
    cmd /c g++ “$(FILE_NAME)” -o “$(NAME_PART)”



  • Thank you, Jim Dailey, that did the trick. I see why that worked now that I look at it. I should have considered that. The forum post that I saw seemed to indicate that the original code that I had without the extra cmd /c should have worked. Now I’m off to learn C++ which looks to be a challenge for an old dog.


Log in to reply