0

Hi I want to know how to compile c++ codes using the command prompt in windows.

In linux I do

g++ filename.cpp -o filename

and run it using

./filename

but for windows when I try this procedure in compiling i got an error message

'g++' is not recognized as an internal or external command,operable program or batch file

I know that the IDE already has a compile button...

please help...

4
Contributors
7
Replies
12
Views
8 Years
Discussion Span
Last Post by sanchyvil
0

I trust you have installed all of the required libraries etc

And set up all global varialbles.

once all is set up i believe this should work

g++.exe "C:\file.cpp" -o "C:\File.cpp" -I"Include directory"  -I"another include directory and so on"  -L"libraries"

and to run it

start C:\file.exe
0

I still have a problem... everytime i close cmd i always need to type

set PATH=%PATH;bin location

before i can use the g++ command.

Is there a way that I can directly use the g++ command after launching cmd?

0

I still have a problem... everytime i close cmd i always need to type

set PATH=%PATH;bin location

before i can use the g++ command.

Is there a way that I can directly use the g++ command after launching cmd?

Yes follow these steps sorry if you already know, i'm going to assume your on XP


1) Right click my computer
2) Select Properties
3) Advanced Tab
5) Environment Variables
6) Under system variables find "Path"
7) Click edit and append with a semicolon separator the new location

And your done, hope that helps

Chris

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.