Community
    • Login

    Trouble Setting Up NppExec to Learn C++

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 2 Posters 2.3k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Steve Daley175S
      Steve Daley175
      last edited by

      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.

      1 Reply Last reply Reply Quote 0
      • Jim DaileyJ
        Jim Dailey
        last edited by

        @Steve-Daley175

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

        1 Reply Last reply Reply Quote 0
        • Steve Daley175S
          Steve Daley175
          last edited by

          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.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors