Community
    • Login

    Run C++ within notepad++

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    12 Posts 6 Posters 14.7k 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.
    • kenn_ugK
      kenn_ug
      last edited by

      Hello learned friends. I am called Ken.

      Iam running windows 10
      I have installed MinGW (Directory is C:\MinGW\bin).
      I have also installed notepad++ (directory is, C:\Program Files (x86)\Notepad++ )
      i have installed the NppExec plugin for Notepad++.

      i would like to run c++ code within notepad++ but i have failed.

      any one to help me out;

      i have tried to use the script below but it has failed.

      npp_save
      cd $(CURRENT_DIRECTORY)
      C:\MinGW\bin\g++
      cmd /c “$(CURRENT_DIRECTORY) \a.exe”

      dinkumoilD Michael VincentM mashrafi diptoM 3 Replies Last reply Reply Quote 0
      • dinkumoilD
        dinkumoil @kenn_ug
        last edited by

        @kenn_ug

        You don’t provide any arguments to g++.exe, the command line even lacks the path to your source file. How should the compiler know what to do?

        Go figure out the required compiler options for your project and read thoroughly the documentation of NppExec, there you can find all information needed.

        kenn_ugK 1 Reply Last reply Reply Quote 1
        • kenn_ugK
          kenn_ug @dinkumoil
          last edited by

          @dinkumoil

          kindly help me out. am trying but can’t figure it out

          1 Reply Last reply Reply Quote 0
          • PeterJonesP
            PeterJones
            last edited by

            @kenn_ug said in Run C++ within notepad++:

            kindly help me out. am trying but can’t figure it out

            How would you do it from the command-line, without Notepad++? Ie, how would you compile the program if you used some other text editor for the source code, or had just downloaded it?

            This is not a compiler forum, or a programming forum. If you tell us how you would compile and run the program without Notepad++, we can help you translate that into how to do it inside Notepad++. But without that, you’re asking us why you cannot bake your cookies.

            1 Reply Last reply Reply Quote 3
            • Michael VincentM
              Michael Vincent @kenn_ug
              last edited by

              @kenn_ug said in Run C++ within notepad++:

              npp_save
              cd $(CURRENT_DIRECTORY)
              C:\MinGW\bin\g++
              cmd /c “$(CURRENT_DIRECTORY) \a.exe”

              Seems like you may just be missing the file to compile:

              npp_save
              cd $(CURRENT_DIRECTORY)
              C:\MinGW\bin\g++ "$(FULL_CURRENT_PATH)"
              cmd /c “$(CURRENT_DIRECTORY) \a.exe”
              
              1 Reply Last reply Reply Quote 3
              • mashrafi diptoM
                mashrafi dipto @kenn_ug
                last edited by

                @kenn_ug you can use this
                npp_save
                cd $(CURRENT_DIRECTORY)
                C:\MinGW\bin\g++ “$(FULL_CURRENT_PATH)” -g -o “$(name_part)”
                cmd /c $(name_part)

                1 Reply Last reply Reply Quote 0
                • william busigoW
                  william busigo
                  last edited by

                  g++: error: no such file or directory
                  ‘new’ is not recognized as an internal or external command, operable program or batch file.
                  Exit code 1

                  PeterJonesP 1 Reply Last reply Reply Quote 0
                  • PeterJonesP
                    PeterJones @william busigo
                    last edited by

                    @william-busigo ,

                    you have to give the file a name and save it somewhere valid.

                    1 Reply Last reply Reply Quote 0
                    • william busigoW
                      william busigo
                      last edited by

                      where is somewhere valid?

                      PeterJonesP 1 Reply Last reply Reply Quote 0
                      • PeterJonesP
                        PeterJones @william busigo
                        last edited by

                        @william-busigo ,

                        where is somewhere valid?

                        Onto your filesystem (HDD/SSD, like the c: drive or d: drive, or onto a USB stick, or wherever).

                        My point was that the g++ error message seemed to say that it couldn’t find the file new. That tells me two things:

                        First, because it says new, I am assuming that it’s actually new 1 or similar, which is what Notepad++ calls tabs that haven’t ever been saved, anywhere. You have to save the file (presumably to something.cpp or similar) before you can run it through a compiler.

                        Second, because the error message says new rather than new 1, I am assuming you don’t actually have the script(s) mentioned above, because you probably don’t have the quotes around the name variables like @Michael-Vincent and @mashrafi-dipto showed above.

                        So make sure you save the file, and give it a meaningful name. Then show us the NppExec script that you are actually running – when you paste it into the forum, make sure to highlight the whole script and hit the </> button, so that it will be surrounded in ``` characters on a line before and after your script in the edit window, and the PREVIEW window will show it in a black box, like @Michael-Vincent’s example above

                        1 Reply Last reply Reply Quote 1
                        • william busigoW
                          william busigo
                          last edited by

                          #include namespace std;
                          int main()
                          (
                          cout << “Welcome to GFG”;

                          return 0;

                          }

                          This file is saved in my Documents Folder with the .cpp extension but when I hit the run button a window opens and tells me to choose “The Program to Run” with a run, save or cancel option instead of just running the program.

                          PeterJonesP 1 Reply Last reply Reply Quote 0
                          • PeterJonesP
                            PeterJones @william busigo
                            last edited by

                            @william-busigo ,

                            This discussion was relying on the fact that everyone involved had the NppExec plugin installed. Everything that has been said in this discussion assumed that as a given.

                            I think before asking any more questions, you need to read and understand our FAQ on “how do I use Notepad++ to compile my source code”.

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