hello there. i've installed mingw compiler and im wondering how i would go about setting up notepad++ to compile my c/c++ code?. How do i do this?

-regards.

Dani AI

Generated

Short, practical clarification and a small ready-to-use NppExec workflow for the OP () and later posters. Two realistic choices are shown: keep Notepad++ as a lightweight editor and call an external compiler, or use a full IDE (Code::Blocks) if you want an out‑of‑the‑box compiler + debugger. was right to point at NppExec for work inside Notepad++; was also right that Code::Blocks bundles a compiler/debugger for an easier start. (d0vgan.github.io)

Minimal NppExec script (save in Plugins → NppExec → Execute, then add it to the menu via Advanced Options). Edit the g++ path if you did not add MinGW/MSYS2 to your PATH:

NPP_SAVE
cd "$(CURRENT_DIRECTORY)"
"C:\path\to\g++.exe" -std=c++17 -Wall -Wextra -g -o "$(NAME_PART).exe" "$(FILE_NAME)"
NPP_RUN "$(NAME_PART).exe"

Notes: replace the compiler path with your actual g++ if it is not globally available; the variables like $(FULL_CURRENT_PATH), $(CURRENT_DIRECTORY), $(FILE_NAME) and $(NAME_PART) are provided by Notepad++/NppExec so the script works across files. To keep output inside Notepad++ use the NppExec console; to run the program in a separate window use NPP_RUN or a cmd /C start /wait trick. (d0vgan.github.io)

Troubleshooting tips:

  • Verify the compiler: open a cmd.exe and run g++ --version (if it fails, add MinGW/MSYS2 bin to PATH or use the absolute path in the script).
  • If paths contain spaces, keep the quotes around variables as in the script.
  • For multi-file projects, switch to a small Makefile or use an IDE—Code::Blocks offers installers that include MinGW if you want an easier setup for debugging and larger projects. (codeblocks.org)

If the goal is learning/quick edits, Notepad++ + NppExec is fine. If you want integrated build configurations, GUI debugger, project management, pick Code::Blocks or another IDE. and others asking about the Run option: the Run menu is useful for single-line commands, but NppExec gives a more reliable scripting workflow inside Notepad++. (npp-user-manual.org)

Recommended Answers

All 15 Replies

hello there. i've installed mingw compiler and im wondering how i would go about setting up notepad++ to compile my c/c++ code?. How do i do this?

-regards.

I assume that the g++ command is in your PATH and that your environment variables are set correctly.

Then follow these steps:

  • Create a simple batch file called compile.bat which contains the following:
    g++ -o %1 %2
    PAUSE
  • Save it in the same directory as your C++ source file.
  • In Notepad++, you open the Plugins menu > NppExec > Follow $(CURRENT_DIRECTORY)
    (or you just press F5), a little dialog pops up, click the ... button and browse to the directory where your source file (and thus your batchfile) is in, select the batchfile (compile.bat) and click on Open, the path to your batchfile is now added to that textbox, now you have to put quotes (") around it, a little example:

    Let's say that the path to your batch file is: C:\compile.bat , then after putting quotes around it it becomes [B]"[/B]C:\compile.bat[B]"[/B] , after that you type the name you want to give to your executable file, for instance myprogram.exe, and thereafter (seperate those two with a space) you type the name of your C++ source file, for example: mysrc.cpp, the whole line would then be:

  • [B]"C:\compile.bat" [I]myprogram.exe[/I] [I]mysrc.cpp[/I][/B]

Hope this helps :)

Please don't mind reading my previous post, just read this article:
:P

commented: Gotta love the simplicity of it all +35
commented: That was an excellent pair of posts :) +9

Why would you want to do that? Just use Code::Blocks and you have it done, and probably much better too. And Code::Blocks contains a debugger, which Notepad++ does not.

hmm...i was hoping to just edit text files without getting into major IDE's.

Member Avatar for Member #248612

Some people use to eat their soup with a fork.......

commented: LOL :) +36

please how do i use notepad to compile my c++ codes with codeblocks

You don't. Notepad is just a text editor, not a compiler. Code::Blocks is distributed with a greate compiler. when you download CB get the distribution that contains MinGW compiler.

Thanks but how do i use the run option in notepad++ when writing c++ codes

What did the NotePad's HELP say about the RUN option.

. . . Code::Blocks is distributed with a greate compiler. when you download CB get the distribution that contains MinGW compiler.

Not to hijack the thread (though the OP hasn't posted here since 2009), but I am presently looking around for a free C++ IDE/compiler myself. Would you recommend Code::Blocks over Visual C++ 2010 Express, or even something else?

: If you are using Code::Blocks why would you want to use Notepad++? Doesn't make any sense.

Not to hijack the thread (though the OP hasn't posted here since 2009), but I am presently looking around for a free C++ IDE/compiler myself. Would you recommend Code::Blocks over Visual C++ 2010 Express, or even something else?

Use Code::Blocks if you want to write portable programs -- its supported on MS-Windows, *nix and MAC. VC++ 2010 is only for MS-Windows, but is the easiest to write MS-Windows programs with any or a combination of several .net languages.

Ok. thanks
just thought i could compile with codeblocks on notepad++

Code::Blocks is not a compiler, its an IDE very much like notepad++.

FWIW the Zeus Lite editor can run an external compiler and capture the compiler error output.

http://www.zeusedit.com/lite/

Just edit the c/c++ document type and add the compiler command line to the compiler panel.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.