5

I downloaded minGW to compile programs in C using the gcc command in the console of Notepad++. I downloaded all the packages so that it could compile other languages as well and I double checked that I have g++.exe just like I have gcc.exe to compile c programs. But I don't get how to get to compile and run c++ programs. I saw the other post, "Getting compiler to work in Notepad", and how he copied and pasted:

NPP_SAVE
CD $(CURRENT_DIRECTORY)
C:\MinGW\bin\g++.exe -g "$(FILE_NAME)"

into the nppExec console. When I do that I get:

NPP_SAVE: C:\Tutorial\helloWorld.cpp
CD: C:\Tutorial
Current directory: C:\Tutorial
C:\MinGW\bin\g++.exe -g "helloWorld.cpp"
Process started >>>
<<< Process finished. (Exit code 0)
================ READY ================

which seems like it works but what do I do next?

here is the program in notepad++

#include <iostream> 

using namespace std; 

int main() {

cout << "Hello World";

}
Sankofa
  • 600
  • 2
  • 7
  • 19
  • You might be better off using an IDE rather than Notepad++ if you want to be able to compile/run/debug etc. [Dev-C++](http://sourceforge.net/projects/orwelldevcpp/) (which also uses g++) and [Visual Studio Express](http://www.visualstudio.com/en-us/products/visual-studio-express-vs.aspx) (the free version of Visual Studio) are options. – softwariness Jan 24 '15 at 23:16
  • OK thank you for your response. I just want to be able to compile and run and I already went through the trouble of downloading minGW because it compiles multiple languages so i just want to put that to use. – Sankofa Jan 24 '15 at 23:28

4 Answers4

7

To be honest I have not tried the nppExec plugin before. (I usually use IDE.) But here is an educated guess:

What you typed in made the code compile, but did not execute the resulting executable. You need to specify the output file, and the run it. It is going to be something like this:

NPP_SAVE
CD $(CURRENT_DIRECTORY)
C:\MinGW\bin\g++.exe -g "$(FILE_NAME)" -o prog.exe
prog.exe
Gábor Angyal
  • 2,225
  • 17
  • 27
3

"which seems like it works but what do I do next?"

Well, I think this way (mis-)using Notepad++ as an IDE, will at least become clumsy, if you want to manage more than a single source (.cpp) file.

As pointed out in Gábor Angyal's answer, the 1st step to go, is to compile an executable using the -o option, and run the created program.

Anyway you should note (if you insist on using Notepad++ instead of a real IDE), that MinGW also supports GNU make (here's a tutorial).
I would recommend to create a Makefile and compile, link and run your code via this one.

If it comes to debug your programs, I will definitely recommend an at least minimal IDE like CodeBlocks or Geany.

Here's a more extended list of suggested Editors/IDE's: Best C++ IDE or Editor for Windows

Community
  • 1
  • 1
πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190
  • Thank you for you input. I will follow up on those IDE if I don't get it to work soon. I took a break and I'm going to get back at it. – Sankofa Jan 25 '15 at 01:25
0

Working script :

NPP_SAVE
CD $(CURRENT_DIRECTORY)
C:\Program Files (x86)\Dev-Cpp\MinGW64\bin\g++.exe -g "$(FILE_NAME)"
iehrlich
  • 3,572
  • 4
  • 34
  • 43
0

This worked for me:

NPP_SAVE

CD $(CURRENT_DIRECTORY)

C:\MinGW\bin\g++.exe -g "$(FILE_NAME)" -o "$(NAME_PART)".exe

"$(NAME_PART)".exe
iminiki
  • 2,549
  • 12
  • 35
  • 45
Taki
  • 1