Compiling on cmd...

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Jun 2008
Posts: 12
Reputation: sanchyvil is an unknown quantity at this point 
Solved Threads: 0
sanchyvil sanchyvil is offline Offline
Newbie Poster

Compiling on cmd...

 
0
  #1
Oct 4th, 2008
Hi I want to know how to compile c++ codes using the command prompt in windows.

In linux I do

  1. g++ filename.cpp -o filename

and run it using
  1. ./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...
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 671
Reputation: Freaky_Chris is a jewel in the rough Freaky_Chris is a jewel in the rough Freaky_Chris is a jewel in the rough 
Solved Threads: 113
Freaky_Chris's Avatar
Freaky_Chris Freaky_Chris is offline Offline
Practically a Master Poster

Re: Compiling on cmd...

 
0
  #2
Oct 4th, 2008
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

  1. 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

  1. start C:\file.exe
Last edited by Freaky_Chris; Oct 4th, 2008 at 1:25 pm.
Knowledge is power -- But experience is everything
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 2,001
Reputation: ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of 
Solved Threads: 343
ArkM's Avatar
ArkM ArkM is offline Offline
Postaholic

Re: Compiling on cmd...

 
0
  #3
Oct 4th, 2008
Your Windows installation does not know where is the g++ executable. See
https://users.cs.jmu.edu/bernstdh/we..._mingw-faq.php
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 236
Reputation: TheBeast32 is on a distinguished road 
Solved Threads: 6
TheBeast32's Avatar
TheBeast32 TheBeast32 is offline Offline
Posting Whiz in Training

Re: Compiling on cmd...

 
0
  #4
Oct 4th, 2008
You need to add the bin directory of MinGW to your PATH environment variable.
"Always program as if the person who will be maintaining your program is a violent psychopath that knows where you live."
--Martin Golding
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 12
Reputation: sanchyvil is an unknown quantity at this point 
Solved Threads: 0
sanchyvil sanchyvil is offline Offline
Newbie Poster

Re: Compiling on cmd...

 
0
  #5
Oct 5th, 2008
tnx for the help guyz!
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 12
Reputation: sanchyvil is an unknown quantity at this point 
Solved Threads: 0
sanchyvil sanchyvil is offline Offline
Newbie Poster

Re: Compiling on cmd...

 
0
  #6
Oct 5th, 2008
I still have a problem... everytime i close cmd i always need to type

  1. 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?
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 671
Reputation: Freaky_Chris is a jewel in the rough Freaky_Chris is a jewel in the rough Freaky_Chris is a jewel in the rough 
Solved Threads: 113
Freaky_Chris's Avatar
Freaky_Chris Freaky_Chris is offline Offline
Practically a Master Poster

Re: Compiling on cmd...

 
0
  #7
Oct 5th, 2008
Originally Posted by sanchyvil View Post
I still have a problem... everytime i close cmd i always need to type

  1. 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
Knowledge is power -- But experience is everything
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 12
Reputation: sanchyvil is an unknown quantity at this point 
Solved Threads: 0
sanchyvil sanchyvil is offline Offline
Newbie Poster

Re: Compiling on cmd...

 
0
  #8
Oct 5th, 2008
tnx for the help chris,
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC