compiling with command prompt

Mar 6, 2014 at 11:47am
Can someone please explain how to compile with this command:
g++ program.cpp -o program

I'm not sure how to use it and what needs to be written before that in command prompt.

thanks!
Mar 6, 2014 at 11:51am
Are you using linux?
If so, then if GCC is installed that is the command you should run in your terminal window while current dirrectory contains your program.cpp
Mar 6, 2014 at 11:55am
oh, sorry, I'm using windows xp
Mar 6, 2014 at 12:04pm
Use the Command Prompt. You can find it under Accessories in the start menu somewhere. Another way is to press Flag key+R, type cmd and then press enter.

This will show a black window that you can type the command into. If program.cpp is not in the current folder you will have to use the cd command to navigate to the correct folder before running the compiler command.

cd path/to/program/folder/
g++ program.cpp -o program
Last edited on Mar 6, 2014 at 12:06pm
Mar 6, 2014 at 12:09pm
After I do that I get this:

'g++' is not recognized as an internal or external command, operable program or batch file
Mar 6, 2014 at 12:12pm
Is the directory containing g++ in your PATH environment variable?
Mar 6, 2014 at 12:12pm
Have you installed the compiler?
Last edited on Mar 6, 2014 at 12:14pm
Mar 6, 2014 at 12:29pm
Yes, I have MinGW.
I used a set path command, now when I write "g++ program.cpp -o program" nothing happens
Mar 6, 2014 at 12:33pm
Thats presumably because it worked. There should now be a program.exe inside the folder: Run it from the command prompt.
Mar 6, 2014 at 12:37pm
:O
it worked!
thank you all so much :D
Topic archived. No new replies allowed.