
-----------------------------------
[Gandalf]
Fri Jul 01, 2005 10:43 pm

Editing/Compiling Programs on Windows
-----------------------------------
Editing/Compiling Programs on Windows Using MinGW
So, you are new to C or C++ and you want to figure out how to get started?  How to run your code?  How to create executables?  Well, here is all you need to know.

EDITORS:

There are quite a few editors for C and C++, and some which even support multiple other languages.  It's up to you to figure out which one works best for you.  Some of the better ones that I am aware of are:

Notepad++: Fully featured editor which supports a wide variety of languages out of the box.
http://notepad-plus-plus.org/

SciTE: Fast and lightweight cross platform editor.  Supports many languages and has a nice syntax highlighting scheme.
http://www.scintilla.org/SciTE.html

Emerald Editor: Another free and easy to use, small editor.  This one also supports a wide variety of programming languages and has macro capabilities.  It is based on Crimson Editor, which is no longer in development.
http://www.emeraldeditor.com/

TextPad: Quite nice, but not completely free.  If you want to keep this editor, you should eventually pay for it.
http://www.textpad.com 
You can get the proper syntax highlighting plugin from:
http://www.textpad.com/add-ons/syna2g.html

Dev-C++:  Included only for the reason that it is extremely popular, Dev C++ is not a stand alone editor, but an all out Integrated Development Environment which uses MinGW/GCC.  For the purposes of this tutorial, we'll assume you're not using Dev-C++.
http://www.bloodshed.net/devcpp.html

COMPILING:

If you want to compile your source code, here is the "best", most straight-forward way.  We will be working with GCC, through the Windows MinGW port, probably the most popular cross platform collection of compilers.  It include compilers for C, C++, Objective C, Java as well as Ada.

First, what you need to do is download it from here:
http://sourceforge.net/projects/mingw/files/latest/download

Next, just install it, no differently than you would install any other program.  You can keep all the configurations and settings as their default; that should be good enough.

Alright, this is the part that you need to pay attention to.  To use the compiler through command prompt, you will need to edit the Windows PATH environmental variable.  If you are using Windows 2000 or Windows XP then you have to:
Right click on My Computer from the desktop.
Select properties.
Go to advanced.
Click environmental variables.
Under system variables select Path
Click edit.
Add ; and then where you installed MinGW to.  If it was C:/Program Files/MinGW then you would add ;C/Program Files/MinGW/bin to the end of what is already there, do not overwrite what is already there!
Now you're done!  To test to see if it worked, and compile programs, open command prompt.  If you don't already have a shortcut then it should be somewhere in the accessories folder in the start menu.

When you are already there, you will see the directory which you are already in.  Now what you need to do is browse to where the source file is.  You will be using DOS style commands, if you are not already familiar with them then: 
type cd  to open a folder and browse it.
type cd .. to go up, 'back' into a more general directory.
type dir to see what folders and files are already in the directory
Now, once you are at the location of your source file, to compile it you have to type:
For C++:
g++ .cpp -o .exe 
For C:
gcc .c -o .exe
For Java:
gcj .java -o .exe
This just specifies which compiler you are using, the source file, and what the resulting executable file will be called.

Good job!  Now just go to the directory where you compiled and double click your program or run it from command prompt by typing in the executable's name.  Hopefully now you will contribute to the C/C++ section and make it as popular as the Turing section. ;)

-----------------------------------
wtd
Fri Jul 01, 2005 10:51 pm


-----------------------------------
+50 bits

Could one of the mods for this section stickify this thread?

-----------------------------------
rizzix
Fri Jul 01, 2005 11:50 pm


-----------------------------------
hmm.. ok.

-----------------------------------
1of42
Fri Jul 01, 2005 11:55 pm

Re: Editing/Compiling Programs on Windows via MinGW
-----------------------------------
Nice post, but:

"]Dev-C++ - Pretty bulky in file size IDE.  "It's a buggy product, and makes the whole process far more complex than it need be."  Still, if you insist, this is a pretty popular free one, and it comes with an editor and compiler.  Since this one is not recommended, I will make you search for it by yourself :twisted:.

wtf? How is it complex? You hit Ctrl+N for a new source file, and F9 to compile/run it. That was a whole 2 steps vs your 14 to compile with command line.

The only time the IDE gets complex is when you get into stuff like Projects, various optimization stuff, class browsing, parsing headers to make lists of functions, etc. 

But you don't need to do that. it's all optional. At the point where you need that, you should be far advanced enough to understand it.

I mean, it's nice and all to be purist and go for the command line, but to deride well-made IDEs like Dev-C++ as bad when you're kinda wrong is pointless.

Plus, it's not even your criticism: you're just parroting wtd. Have an original thought. :roll:

-----------------------------------
wtd
Sat Jul 02, 2005 12:33 am


-----------------------------------
Those steps are pretty much all one-time investments.  You don't have to install MinGW each time you want to compile something.

Besides, the fact of the matter is that any IDE adds complexity to the process of writing the kind of simple programs that students typically write.  IDEs may add convenience to the creation of larger programs, but these aren't larger programs people are writing.

-----------------------------------
[Gandalf]
Sat Jul 02, 2005 3:44 pm


-----------------------------------
Thanks for the bits and sticky :).

Well, first off, this was mostly a tutorial about command line compiling, so that is why I kept the IDE section small.  Dev-C++ can only do C and C++, while if you want to switch to say, Java later on then you don't need any new install or worrying about installing anything.  I find it pretty handy just having command prompt open on my C++ directory and having a simple editor window open.  It's easy to switch, and it doesn't require as much resources.  Also, notice the quotes, I did take this from wtd,  and I find it to be true.  Some of the syntax-type bugs in Dev-C++ are really annoying, especially if you are new, and I don't find them in other editors.

Besides, keep in mind that I was writing this around midnight ;).

*Edit*  Another reason why I dislike Dev-C++, for some messed up reason it doesn't allow you to install to a directory with a space in the name, so I couldn't install it to C:/Program Files.

-----------------------------------
rizzix
Sat Jul 02, 2005 7:15 pm


-----------------------------------
*sigh* may i recommend Eclipse for you Java/C/C++/PHP/Perl/Ruby/Python/Groovy/COBOL/Fortran development? ...tsk tsk tsk...  :snooty:

-----------------------------------
wtd
Sat Jul 02, 2005 9:24 pm


-----------------------------------
My IDE is called "Linux".  My editor is gEdit.  My compiler/interpreter is bash.  My integrated documentation browser is Firefox and Google.  My debugger is my brain.

-----------------------------------
1of42
Sat Jul 02, 2005 11:25 pm


-----------------------------------
My IDE is called "Linux".  My editor is gEdit.  My compiler/interpreter is bash.  My integrated documentation browser is Firefox and Google.  My debugger is my brain.

And all of that could be had in 1 IDE. :roll:

-----------------------------------
wtd
Sun Jul 03, 2005 12:25 am


-----------------------------------
My IDE is called "Linux".  My editor is gEdit.  My compiler/interpreter is bash.  My integrated documentation browser is Firefox and Google.  My debugger is my brain.

And all of that could be had in 1 IDE. :roll:

Nawww... my brain would still need to be a separate part of the process.  :)

-----------------------------------
1of42
Sun Jul 03, 2005 1:45 am


-----------------------------------
My IDE is called "Linux".  My editor is gEdit.  My compiler/interpreter is bash.  My integrated documentation browser is Firefox and Google.  My debugger is my brain.

And all of that could be had in 1 IDE. :roll:

Nawww... my brain would still need to be a separate part of the process.  :)

Don't bet on it... mwahahahahaha ;)

-----------------------------------
Mazer
Sun Jul 03, 2005 7:29 pm


-----------------------------------
*sigh* may i recommend Eclipse for you Java/C/C++/PHP/Perl/Ruby/Python/Groovy/COBOL/Fortran development? ...tsk tsk tsk...  :snooty:
Well, I can't speak in regards to the other languages, but I've tried Eclipse for Python programming. The first time I tried it, I was not terribly impressed. The second time I tried it, I somehow just couldn't manage to get the PyDev installed properly even while trying several different guides each time (yes, I know there are other Python plugins available, but I'd wasted enough time already at that point).

gEdit works quite nicely. The only thing I could ask for is a little button (and/or hotkey) to call the python interpreter for the current file so that I don't need to keep a terminal open when I'm not getting any input or output from it.

And though it came with my distro already, I'm betting gEdit would be much less than an 80MB+ download  :P

-----------------------------------
wtd
Sun Jul 03, 2005 10:35 pm


-----------------------------------
Coutsos, go into Preferences -> Plugins, and enable the Shell Command plugin.  Then find it under the Tools menu. :)

-----------------------------------
Mazer
Mon Jul 04, 2005 8:32 pm


-----------------------------------
*wipes tear from eye* Bless you, wtd!

-----------------------------------
scuff
Sun Jul 24, 2005 6:17 pm


-----------------------------------
I'm wanting to start some programming with OpenGL.  Until now I have been using Dev-C++ as a compiler but it does not work right with the OpenGL code I got from NeHe (http://nehe.gamedev.net).  Is there a better FREE compiler for this.

-----------------------------------
wtd
Sun Jul 24, 2005 6:20 pm


-----------------------------------
I'm wanting to start some programming with OpenGL.  Until now I have been using Dev-C++ as a compiler but it does not work right with the OpenGL code I got from NeHe (http://nehe.gamedev.net).  Is there a better FREE compiler for this.

Dev-C++ does not have its own unique compiler.  It simply uses the GNU compiler, but does a poor job of it.

Follow the instructions provided in this thread to obtain MinGW.  Or install Linux.

-----------------------------------
1of42
Sun Jul 24, 2005 6:21 pm


-----------------------------------
Dunno what you're doing wrong, but I've compiled several of those examples and they work fine in Dev-C++.

Make sure to download the glaux header though, I think it's available under updates/packages.

-----------------------------------
Hikaru79
Mon Jul 25, 2005 10:52 pm


-----------------------------------
Hmm... in your guide, when you're adding to the path, I'm pretty sure you'd have to add: C:/Program Files/MinGW/bin

It doesnt add directories to the path recursively. So adding just /MinGW/ wouldn't do anything.

-----------------------------------
[Gandalf]
Wed Aug 17, 2005 5:18 pm


-----------------------------------
"]7. Add ; and then where you installed Java to.  If it was C:/Program Files/MinGW then you would add ;C/Program Files/MinGW to the end of what is already there, do not overwrite what is already there!
Heh, yeah, I guess I was a bit sleepy when I wrote this, JAVA!!  and nobody noticed. :lol:

About /bin I will check that either today or tomorrow to make sure, anybody else able to confirm that?

-----------------------------------
Hikaru79
Thu Aug 18, 2005 11:52 pm


-----------------------------------
"]"]7. Add ; and then where you installed Java to.  If it was C:/Program Files/MinGW then you would add ;C/Program Files/MinGW to the end of what is already there, do not overwrite what is already there!
Heh, yeah, I guess I was a bit sleepy when I wrote this, JAVA!!  and nobody noticed. :lol:

About /bin I will check that either today or tomorrow to make sure, anybody else able to confirm that?
Yeah, I just checked. I wasn't sure about it when I wrote that, but I am now. You have to add /bin to the path entry, it won't look any deeper into subdirectories.

-----------------------------------
wtd
Fri Aug 19, 2005 12:19 am


-----------------------------------
"]"]7. Add ; and then where you installed Java to.  If it was C:/Program Files/MinGW then you would add ;C/Program Files/MinGW to the end of what is already there, do not overwrite what is already there!
Heh, yeah, I guess I was a bit sleepy when I wrote this, JAVA!!  and nobody noticed. :lol:

About /bin I will check that either today or tomorrow to make sure, anybody else able to confirm that?
Yeah, I just checked. I wasn't sure about it when I wrote that, but I am now. You have to add /bin to the path entry, it won't look any deeper into subdirectories.

Which is how things should work.

-----------------------------------
Geminias
Thu Sep 22, 2005 12:26 am


-----------------------------------
NOTE:  if you are compiling C++ and the command g++ is not recognized even after you ensure that you have specified the right path in the variables, 

try renaming g++ command to mingw, or something that doesn't contain the ++'s.

-----------------------------------
[Gandalf]
Thu Sep 22, 2005 3:19 pm


-----------------------------------
Fixed the /bin path part, missed last few posts for some reason :?.

-----------------------------------
TokenHerbz
Sat Oct 29, 2005 4:14 am


-----------------------------------
Gandalf wrote:

Alright, now is the part that you need to pay attention to. To use the compiler through command prompt, you will need to edit the Windows PATH environmental variable. If you are using Windows 2000 or Windows XP then you have to:
1. Right click on My Computer from the desktop.
2. Select properties.
3. Go to advanced.
4. Click environmental variables.
5. Under system variables select Path
6. Click edit.
7. Add ; and then where you installed MinGW to. If it was C:/Program Files/MinGW then you would add ;C/Program Files/MinGW/bin to the end of what is already there, do not overwrite what is already there!


Im on Windows 98...   i tryed to follow those steps but its no good, stopped at step 3...

can you or wtd post the steps for Win 98?  thanks.

-----------------------------------
Hikaru79
Sat Oct 29, 2005 4:00 pm


-----------------------------------
Here's a guide for [url=http://www.chem.gla.ac.uk/~louis/software/faq/q1.html]setting environment variables in Windows 98. I'm hoping you'll be able to follow along with that guide. Simply use those instructions to set the environment variable that Gandalf's instructions tell you to. It should all be good.

Ask if you're confused about something.

-----------------------------------
Saad85
Fri Dec 30, 2005 11:42 am

Re: Editing/Compiling Programs on Windows via MinGW
-----------------------------------
"]Now, once you are at the location of your source file, to compile it you have to type:
For C++:
g++ .cpp -o .exe 
For C:
gcc .c -o .exe
For Java (not sure about this one):
gcj .java -o .exe

sorry, but im completely new to c++ and am trying to get started. what do you mean by the source? and what am i supposed to put in for the names of the files?

-----------------------------------
wtd
Fri Dec 30, 2005 2:42 pm


-----------------------------------
Source code is the text you type in to create your program.  Object code is the binary gunk that gets fed to your computer after being created by a compiler.

A "source file" is the text document containing the program as you have written it.

-----------------------------------
Geminias
Fri Dec 30, 2005 9:56 pm


-----------------------------------
incase you didn't understand wtd (he often communicates ineffectively by adding too much jargon) 

source code:  programming languages are all considered to be codes, so when you write a program you have written it in code, because computers do not understand english (yet).  source code is a term which refers to a programs code.  it is a sensible term because the source of any program is its code, so if you wanted to see the reason behind a programs behaviour a good place to start would be in the source code.  

name of file:  is quite simply the name of the file.    is surrounded by those funny brackets to indicate that it is user inputted.  so for instance: if you save a text file as MyProgram.cpp that is the name of the file.

-----------------------------------
wtd
Fri Dec 30, 2005 10:35 pm


-----------------------------------
Please refrain from personal attacks.  They detract from the quality of the discussions here.

If you have something against me, just come out and say it, but do so elsewhere.

-----------------------------------
Geminias
Fri Dec 30, 2005 11:53 pm


-----------------------------------
it was not a personal attack, it was both a justification and a notification.  a justification to expound on your response.  a notification to him that he can expect not to understand what you mean many times in the future.  

communicating above the level of others is what i said you do, nothing more.  if that is a personal attack, then i sincerely do appoligize.  I only wish my greatest weakness was communicating above the level of others...

and again, i have nothing against you wtd, i have nothing against anyone.

-----------------------------------
wtd
Sat Dec 31, 2005 12:01 am


-----------------------------------
For me, it's a personal attack when you suggest to others that they disregard what I have to say.

Nothing in my reply was overly complex.  If anything my response was simpler and more to the point than yours.

-----------------------------------
Geminias
Sat Dec 31, 2005 1:10 am


-----------------------------------
quote the line where it is implied that others disregard what you have to say.

if you read what i typed carefully you will notice that i said "if" you did not understand wtd's answer, then here's a different way of putting it... and i offered a more elaborate answer, and yes, it was less concise.  Often when teaching you should use jargon very judiciously.  This helps pupils to take in the main concept, but the drawback is of course lack of precision.  

please don't respond if you still think i'm knocking you in some way since my case has finished being presented.  i have nothing further to defend my position, if the jury is dissatisfied then too bad.

-----------------------------------
rizzix
Sat Dec 31, 2005 1:52 am


-----------------------------------
incase you didn't understand wtd (he often communicates ineffectively by adding too much jargon) 

source code:  programming languages are all considered to be codes, so when you write a program you have written it in code, because computers do not understand english (yet).  source code is a term which refers to a programs code.  it is a sensible term because the source of any program is its code, so if you wanted to see the reason behind a programs behaviour a good place to start would be in the source code.  

name of file:  is quite simply the name of the file.    is surrounded by those funny brackets to indicate that it is user inputted.  so for instance: if you save a text file as MyProgram.cpp that is the name of the file.

lol plz... the basic "jargon" used by wtd was very effective.. your's on the other had was unnecessary verbose.. It is EXPECTED that the student/programmer knows at least that bit of jargon... geez

And yes that quote did sound pretty offensive... specifically these lines:incase you didn't understand wtd (he often communicates ineffectively by adding too much jargon)  And then you further go about with the pointless unanimous definitions of obvious jargon.

-----------------------------------
Geminias
Sat Dec 31, 2005 1:58 am


-----------------------------------
you're right, i was completely out of line.  You're also right that his use of jargon was inconsequential in this instance, but this is not always the case.  More than anything i found his explanation inadequate so i decided to pipe up.  

how come rizzix i only hear from you when you have something negative to input?  

i only ask because generally i don't pay much attention to people who can only be bothered to say negative about me.

-----------------------------------
Naveg
Sat Dec 31, 2005 2:17 am


-----------------------------------
Just give it up. wtd is very highly respected here at compsci.ca, not only because of his wealth of programming knowledge, but also because of his kind, welcoming attitude towards beginners. For you to personally attack him when he is trying to help someone else out is very rude and disrespectful. We don't tolerate this attitude toward anyone at compsci.ca, much less a high-standing member of the community. And please don't accuse myself, rizzix, or anyone else who tries to put you in the right place.

i don't pay much attention to people who can only be bothered to say negative about me.

Good, so that's settled then. Leave us alone, and we'll leave you.

-----------------------------------
rizzix
Sat Dec 31, 2005 2:18 am


-----------------------------------
how come rizzix i only hear from you when you have something negative to input?

Short answer: I haven't had enough Java lately!

Long answer: I think I've mentioned this before. I only bust in when I see something wrong, gone uncorrected. In this case wtd most likely had no intention of continuing this pointless debate. I, on the other hand, felt I might as well destroy that little dignity left in you for the sake of YACM (Yet Another Compsci Mod). Eitherway, if it wasn't for me, it would have been another mod. Believe me! So consider your self lucky that it was in fact the good O'l me. That way you can safely blame it on the all-so-fictitious pessimistic character of mine.

-----------------------------------
Geminias
Sat Dec 31, 2005 2:32 am


-----------------------------------
holy macro naveg...  

thats cool rizzix, i understand i can't really win against wtd.  but i just found that when he teaches me i spend a lot of time puzzling over what he is actually saying let alone the programming aspect of it all.  i really didn't think it was being rude, i thought it more constructive criticism which is why i mentioned it.  i never say anything to be rude.

i have the mind of a noob still so i think it is easier for me to say what a noob can understand and what he can't.  i trully believe my input in this matter should not be ignored.  wtd should thank me for reminding him how stupid noobs really are.

if you guys think i'm wrong isn't there a nice way to tell me?  or perhaps, if your not used to posting in the c++ section, why would you post the moment you see a flame war?

-----------------------------------
wtd
Sat Dec 31, 2005 2:39 am


-----------------------------------
Novice programmers aren't stupid.  They're ignorant.  Ignorance can be addressed.

-----------------------------------
Geminias
Sat Dec 31, 2005 2:54 am


-----------------------------------
we are all ignorant of something, all people are ignorant.  in my oppinion ignorant is as petty a thing to call a noob as stupid is.   

since i'm obviously walking on nails here (a metaphor describing how i feel when i'm typing a message in this topic)  "stupid" was a stupid thing for me to call them, obviously.  but i was being lazy and needed an adjective we can all relate too, so stupid just sort of came out.  why am i explaining this?  

because wtd is a more learned programmer than me, but no one is more learned in life than anyone else.  let that be known.

-----------------------------------
wtd
Sat Dec 31, 2005 3:34 am


-----------------------------------
Ignorant is not a negative thing to call someone.  It's just a word.  If it's a lie, then that's negative, but it'd be negative because of being a lie.

Willful ignorance is another matter.  That is negative, but again, it's not the ignorance that makes it bad.

Being able to accurately use words is part of communicating effectively, and it's a big part of being a programmer.  We all need help (myself no less than anyone else), and being able to ask a question clearly makes getting help much easier.  What you know is not nearly so important as how quickly you can learn the things you don't know, because there's a lot more of the latter.

Also, you are not exhibiting true laziness.  True laziness would involve knowing how to properly use words so that inaccurate use of them does not provoke a debate.  Remember: taking a few minutes to get things right is much lazier than spending hours fixing it later.  :)

-----------------------------------
Saad85
Sun Jan 01, 2006 12:21 am


-----------------------------------
im sorry if i caused this, but plz, both of you-- stfu and program something


oh btw, thx to both of you for explaining that
^^  :)

-----------------------------------
wtd
Sun Jan 01, 2006 12:27 am


-----------------------------------
You asked a question.  There's nothing wrong with that.

-----------------------------------
wtd
Sun Jan 01, 2006 12:28 am


-----------------------------------
A question is only stupid the second or later time you ask after receiving a good answer.  :)

-----------------------------------
Geminias
Sun Jan 01, 2006 1:41 am


-----------------------------------
Also, you are not exhibiting true laziness. True laziness would involve knowing how to properly use words so that inaccurate use of them does not provoke a debate. 

for the record, i was exhibiting true laziness by using the adjective "stupid".  I am deeply aware of this reality and i know that stupid is not the right word.  however, i don't like to talk serious very often because i am not a serious person.  but, i consistantly have found myself defending the fact that i know better because of your stringentness, to the point where it has become noted.  i think you underestimate me, when the fact is you just bore me when you go off and get all "politically correct" when i'm just trying to deintensify a "serious" conversation.  

[/quote]

-----------------------------------
[Gandalf]
Sun Jan 01, 2006 1:55 am


-----------------------------------
I must comment on this...
i have nothing against anyone
This is clearly false, unless you have had no experiences which is obviously not true.  You should really watch your wording if you wish to prevent things like this from happening more often.

Anyways, this topic better not be locked because of this or else Gandalf +  :( = Wrath.  hehe
*The above hehe does not in any way specify that the poster is joking.

-----------------------------------
Geminias
Sun Jan 01, 2006 4:17 am


-----------------------------------
i dont have anything against anyone.  by that i mean if wtd needed my help i wouldn't hesitate to offer it to him.  and in the future i would never hold this argument over him.  that is what i mean by i have nothing against anyone.  

on the other side, i have had plenty of experiences and never have i held a grudge.  people have disappointed me before, yes... but people are people and i happen to understand why people do as they do.  you could mass murder my whole family or destroy my two thousand dollar computer, i wouldn't hold it against you.  

jesus christ, i believe, had this same message, even though i don't think he was the son of god, he sure was a fine addition to humanity.  

if anyone else has some inferences about me they'd like to share i'd suggest that they don't know what they are talking about and perhaps maybe they could keep it to themselves.

-----------------------------------
Naveg
Sun Jan 01, 2006 10:54 am


-----------------------------------
You seriously need to learn when its time to give something up. This is a completely useless argument and you are getting no where. It's enough already.

If you want to post in this thread, it better be related to Compiling C/C++ with MinGW, or we don't want to hear it.

-----------------------------------
TokenHerbz
Tue Mar 07, 2006 6:02 pm


-----------------------------------
Gandalf Wrote:


Alright, now is the part that you need to pay attention to. To use the compiler through command prompt, you will need to edit the Windows PATH environmental variable. If you are using Windows 2000 or Windows XP then you have to:
1. Right click on My Computer from the desktop.
2. Select properties.
3. Go to advanced.
4. Click environmental variables.
5. Under system variables select Path
6. Click edit.
7. Add ; and then where you installed MinGW to. If it was C:/Program Files/MinGW then you would add ;C/Program Files/MinGW/bin to the end of what is already there, do not overwrite what is already there! 


Well Gandalf, how does one set this up with Windows 98?

-----------------------------------
Justin_
Tue Mar 07, 2006 8:22 pm


-----------------------------------
If he knew he would have said so.  But try googling "changing PATH in win98" or "editing environment variables in win98"

-----------------------------------
md
Tue Mar 07, 2006 8:35 pm


-----------------------------------
Gandalf Wrote:


Alright, now is the part that you need to pay attention to. To use the compiler through command prompt, you will need to edit the Windows PATH environmental variable. If you are using Windows 2000 or Windows XP then you have to:
1. Right click on My Computer from the desktop.
2. Select properties.
3. Go to advanced.
4. Click environmental variables.
5. Under system variables select Path
6. Click edit.
7. Add ; and then where you installed MinGW to. If it was C:/Program Files/MinGW then you would add ;C/Program Files/MinGW/bin to the end of what is already there, do not overwrite what is already there! 


Well Gandalf, how does one set this up with Windows 98?
Umm... upgrade to 2000 at least. Windows 98 is rather old and unsupported now...

-----------------------------------
TokenHerbz
Tue Mar 07, 2006 9:28 pm


-----------------------------------
i cannot upgrade, i must work with this, is it possible?

-----------------------------------
md
Tue Mar 07, 2006 9:35 pm


-----------------------------------
IIRC windows 98 still parses the autoexec.bat file; perhaps specifying your path in it might help

-----------------------------------
wtd
Tue Mar 07, 2006 9:46 pm


-----------------------------------
I tried to walk him through that.  Apparently he isn't capable of modifying autoexec.bat.

-----------------------------------
rizzix
Wed Mar 08, 2006 1:16 am


-----------------------------------
Install linux.

-----------------------------------
TokenHerbz
Wed Mar 08, 2006 4:17 pm


-----------------------------------
um, i dont want to use linux, and my autobat file dosn't open up, and when i di open up, its a bunch of giberish,  any other ideas?

-----------------------------------
Onega
Mon May 08, 2006 12:06 am


-----------------------------------
IMO, Code::Blocks is better than textpad and crimson editor.
It is an open source free IDE available at www.codeblocks.org/ 

-----------------------------------
[Gandalf]
Mon May 08, 2006 12:37 am


-----------------------------------
Thanks for the information (hadn't heard of it before), but the main purpose of the post was editors and setting up MinGW.  I probably should have completely left out DevC++ to avoid all that confusion/misunderstanding.

-----------------------------------
CodeMonkey2000
Fri Feb 02, 2007 10:33 pm

RE:Editing/Compiling Programs on Windows
-----------------------------------
Help! What does "g++: installation problem, cannot exec `cc1plus': No such file or directory" mean?

-----------------------------------
haskell
Sun Feb 04, 2007 4:35 pm

Re: Editing/Compiling Programs on Windows
-----------------------------------
@ spearmonkey: Usually means you don't have the gcc-core package.

 Dev-C++ is not a good choice. I'd elaborate, but its a waste of energy.

 Relo[http://www.fifsoft.com/relo/] is decent of C++ development. 

 Emacs with cc-mode[http://cc-mode.sourceforge.net/] is also a great choice.

 I also recommend OpenWatcom[http://www.openwatcom.org/index.php/Main_Page] for Windows users. It supplies executables to emulate Microsoft C++ Compilers, plus it is open source.

-----------------------------------
blood8815
Thu Feb 08, 2007 8:17 pm

RE:Editing/Compiling Programs on Windows
-----------------------------------
im having trouble getting the source file, I have MinGW and Crimson Editor

BTW, im new

-----------------------------------
Clayton
Thu Feb 08, 2007 9:10 pm

Re: Editing/Compiling Programs on Windows
-----------------------------------
Have you run the MinGW installer? If not, do so. After that make sure you edit your PATH variable (following Gandalf's instructions). Now you can write a program. Open up crimson editor and write a Hello World program to test. Save it as a .cpp file to a directory that you can navigate to easily from the command line. Open up the command prompt (as I'm assuming you're using Windows) and navigate to the directory where the file is. Then type in the following:

prompt>> g++ .cpp -o .exe
      >>

and if all goes well, your program will execute.

-----------------------------------
CodeMonkey2000
Sun Mar 25, 2007 2:06 pm

RE:Editing/Compiling Programs on Windows
-----------------------------------
I keep getting the " 'g++' isn't recognized as an internal or external command, operable program or a batch file". What gives? I set up my Path variable and g++ is still not recognized :(

-----------------------------------
CodeMonkey2000
Sun Mar 25, 2007 2:32 pm

RE:Editing/Compiling Programs on Windows
-----------------------------------
Never mind, I fixed it.

-----------------------------------
klopyrev
Sun Mar 25, 2007 3:47 pm

Re: Editing/Compiling Programs on Windows
-----------------------------------
I've always used Ready to Program for Java and I find it to be the easiest to use IDE ever. I don't work on big projects, mostly stand-alone files. You just open the IDE, type in the code, press F2 to auto-indent everything, press F1 to run. That's all there is to it. The most convinient feature is the Auto-indentation. No matter how badly indented your code may be (even if its all in 1 line or something), the F2 button will make it perfect. Since I started C++, I've been looking for a simple editor like that. Does anyone know one?

KL

-----------------------------------
Clayton
Sun Mar 25, 2007 5:04 pm

Re: Editing/Compiling Programs on Windows
-----------------------------------
Are you using the hsa.Console class, or any other classes that are solely for RTP? If you are, I would suggest that you not use them any longer.

-----------------------------------
klopyrev
Sun Mar 25, 2007 5:51 pm

Re: Editing/Compiling Programs on Windows
-----------------------------------
I really don't like the hsa stuff, except for perhaps graphics. For just test input, output, Console is just so messy. I like the basic System stuff.

-----------------------------------
ericfourfour
Sun Mar 25, 2007 11:15 pm

Re: Editing/Compiling Programs on Windows
-----------------------------------
This one isn't as simple as double-click the icon, type in your code, press F2, then F1, it is more complex but has "the auto-indentation" and "single key-press run the program" functions that RTP has.

The NetBeans IDE has a function called reformat code which reformats your code the way you like it. It is primarily used for Java development, but there is a c++ plugin for it (in the next version it will support Ruby too). I'm not sure if the reformat button is a single key-press, I think it might require a combination of two or more keys. It can also compile and run programs with a simple press of the F6 key.

Using this IDE is usually for larger project so it might not be what you are looking for.

Really, you should just be working with the command line if your not doing anything really fancy.

You are learning c++ for the contest in Waterloo right? In that case, you should find out what is used there. :)

-----------------------------------
allen.c++
Fri Jul 06, 2007 8:59 pm

Re: Editing/Compiling Programs on Windows
-----------------------------------
sry, new to c++ but not to compsci.ca, juz wondering i wanted to learn c++ over the summer so i can prepare for g12 ( even tho we are doing more advance turing and not c++ ) , i chose to go with textpad since ive heard many good comments said about it. but which puglin shud i be dling? which is the "proper" plugin?

and the procedure where we had to edit the path in advance property, how wud that effect the computer?

so from my understanding so far we had the MinGw, an editor, so we creat the code functions and what not using the editor, and by installing and using MinGw we open the file we created using the editor ( in my case the texpad ) from the command promt?

sorry for being so noob but seriously in need of help and answers :P


reason why i chose textpad :  wanted to learn c++ the "complete" way and not taking shortcuts by using programs that does the job for you, such as textpad to dreamweaver in websites.

please give me some reply/comment on my choice and reason for chosing textpad also if possible

-----------------------------------
rdrake
Fri Jul 06, 2007 10:34 pm

RE:Editing/Compiling Programs on Windows
-----------------------------------
You write the programs in your editor (in your case, Textpad).  You then switch over to the command line and compile the program.  You can then run it.  You really shouldn't need a plug-in for Textpad to do this.

Changing your path should not do anything harmful to your system.  Just add it after what's already defined for PATH, separating the new entry from the old with a semi colon.

-----------------------------------
FileFantasy
Wed Aug 08, 2007 6:08 pm

RE:Editing/Compiling Programs on Windows
-----------------------------------
Hey, when I try to compile a .java file into .exe with MinGW by:

gcj hi.java -o hi.exe

It gives me this in command prompt:

\bin\ld.exe: cannot find -liconv
collect2: ld returned 1 exit status

And the .exe is not created.

What's wrong?

(The .java contains your typical HelloWorld code)

-----------------------------------
wtd
Wed Aug 08, 2007 8:58 pm

RE:Editing/Compiling Programs on Windows
-----------------------------------
[url=http://www.linuxjournal.com/article/4860#comment-15294]Google is your friend.

-----------------------------------
saltpro15
Mon Jan 05, 2009 7:12 pm

RE:Editing/Compiling Programs on Windows
-----------------------------------
I'm just getting into c++, I am so absolutely sick of Turing it's ridiculous.  First off, thanks for this awesome thread, helped me a lot.  That editor is great, and this is so embarrasing to ask but it's better to be embarassed and learn something than to be cool and learn nothing, so what are compilers for?  My teacher hasn't taught any c++ to us and doesn't have the time to help me, so I'm relying on the gods of compsci!

-----------------------------------
Insectoid
Mon Jan 05, 2009 7:21 pm

RE:Editing/Compiling Programs on Windows
-----------------------------------
Compilers turn the english (well, sort of english) code into binary so that the computer can read it. Turing compiles automatically before running. Some languages are interpreted, meaning they 'compile' while they run.

-----------------------------------
DemonWasp
Tue Jan 06, 2009 11:55 am

RE:Editing/Compiling Programs on Windows
-----------------------------------
Worth noting: Turing is interpreted, meaning that there's a program (called an interpreter, strangely enough) that reads your code as and runs it.

Compilers work slightly differently: they change your code into a format that works directly on the computer. There's no other program running to interpret your code, and your code is no longer in the executable.

Both approaches have a laundry list of advantages and disadvantages.

-----------------------------------
alex141323
Tue Aug 03, 2010 9:00 am

Re: Editing/Compiling Programs on Windows
-----------------------------------
[quote="[Gandalf]
[*]Add ; and then where you installed MinGW to.  If it was C:/Program Files/MinGW then you would add ;C/Program Files/MinGW/bin to the end of what is already there, do not overwrite what is already there![/list]
Now your done. [/quote]

Im having difficulty in that part.what should i do in there?.the only choices when you click edit is variable name and variable value.should i add it in F:\Program Files\PC Connectivity Solution\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem???

I really dont know how to work this out.:( im just a new programmer.

-----------------------------------
TheGuardian001
Tue Aug 03, 2010 12:23 pm

Re: Editing/Compiling Programs on Windows
-----------------------------------
Add ; and then where you installed MinGW to.  If it was C:/Program Files/MinGW then you would add ;C/Program Files/MinGW/bin to the end of what is already there, do not overwrite what is already there!

Im having difficulty in that part.what should i do in there?.the only choices when you click edit is variable name and variable value.should i add it in F:\Program Files\PC Connectivity Solution\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem???

I really dont know how to work this out.:( im just a new programmer.

If your original PATH variable was, for example
Ninja-Wizard edit:  Quite to the contrary, quote Gandalf at your leisure!  In fact, quote Gandalf moar!

-----------------------------------
atal
Sun Jul 17, 2011 10:55 am

RE:Editing/Compiling Programs on Windows
-----------------------------------
Which one of the two do i need a:

1. C++ Editor and complier
                or
2. Editor and complier

-----------------------------------
Nick
Sun Jul 17, 2011 6:31 pm

Re: RE:Editing/Compiling Programs on Windows
-----------------------------------
Which one of the two do i need a:

1. C++ Editor and complier
                or
2. Editor and complier


either or, as long as the compiler is a C++ compiler.

C++ code is merely text, just like another other code. It doesn't become machine language until you pass it to a compiler.

If you wanted to, you could open a Java IDE, write C++ code, take the file and give it to a C++ compiler, and have running code.

I recommend either a C++ IDE, or just Notepad++.

-----------------------------------
atal
Mon Jul 18, 2011 11:22 am

Re: RE:Editing/Compiling Programs on Windows
-----------------------------------
Which one of the two do i need a:

1. C++ Editor and complier
                or
2. Editor and complier


either or, as long as the compiler is a C++ compiler.

C++ code is merely text, just like another other code. It doesn't become machine language until you pass it to a compiler.

If you wanted to, you could open a Java IDE, write C++ code, take the file and give it to a C++ compiler, and have running code.

I recommend either a C++ IDE, or just Notepad++.

ok. Thanks and the complier i use is DEV-C++

-----------------------------------
atal
Mon Jul 18, 2011 11:28 am

Re: Editing/Compiling Programs on Windows
-----------------------------------
Hey i am totaly new to this. can someone explain this part to me

[quote]
Now your done. To test to see if it worked, and compile programs, open command prompt. If you don't already have a shortcut then it should be somewhere in the accessories folder in the start menu.

When you are already there, you will see the directory which you are already in. Now what you need to do is browse to where the source file is. You will be using DOS style commands, if you are not already familiar with them then:

    type 
Now your done. To test to see if it worked, and compile programs, open command prompt. If you don't already have a shortcut then it should be somewhere in the accessories folder in the start menu.

When you are already there, you will see the directory which you are already in. Now what you need to do is browse to where the source file is. You will be using DOS style commands, if you are not already familiar with them then:

    type cd  to open a folder and browse it.
    type cd .. to go up, 'back' into a more general directory.
    type dir to see what folders and files are already in the directory


Now, once you are at the location of your source file, to compile it you have to type:

    For C++:
    g++ .cpp -o .exe
    For C:
    gcc .c -o .exe
    For Java:
    gcj .java -o .exe


This just specifies which compiler you are using, the source file, and what the outputted executable file will be called. to open a folder and browse it.
    type cd .. to go up, 'back' into a more general directory.
    type dir to see what folders and files are already in the directory

-----------------------------------
apython1992
Mon Jul 18, 2011 2:36 pm

RE:Editing/Compiling Programs on Windows
-----------------------------------
This is trying to teach you how to compile and execute your programs from the command line, rather than through an IDE (by the way, DevC++ is an IDE, not a compiler). I think you should scrap learning with an IDE and use a plain text editor (even Notepad, so you can really learn that source code is just plain text) and a command prompt.  Tell us what part of that you don't understand, because it's a lot of work to explain it all when you are probably struggling with only a small part of it.

-----------------------------------
Gadd
Wed Apr 11, 2012 8:27 pm

RE:Editing/Compiling Programs on Windows
-----------------------------------
Where the hell is Code::Blocks e.e

-----------------------------------
Cancer Sol
Fri Apr 05, 2013 6:18 pm

Re: RE:Editing/Compiling Programs on Windows
-----------------------------------
Where the hell is Code::Blocks e.e
What's e.e?
Are you talking about an .exe? That would be in the Code Blocks folder I guess?
Or if you're asking where to download it... http://lmgtfy.com/?q=code+blocks+mingw+download.
