As mentioned in the previous section, an Integrated Development Environment (IDE) contains all of the things you need to develop, compile, link, and debug your programs. So let’s install one.
The obvious question is, “which one?”. Keep in mind that you can install multiple IDEs, so there is no “wrong decision” here. During the course of these tutorials, we will be showing you some of the nice features of your IDE, such as how to do integrated debugging. All of our examples will be done using both Microsoft’s Visual C++ 2005 Express Edition, and Code::Blocks. Thus we highly recommend you pick one of these.
However, if you are tech savvy and would like to try your hand at another compiler, you are free to do so. The concepts we show you will work for any IDE — however, different IDE’s use different keymappings and different setups, and you may have to do a bit of searching to find the equivalent of what we show you.
Windows
If you are developing on a Windows machine (as most of you are), then we highly recommend Microsoft’s free Visual C++ 2008 Express Edition. The installer that you download off of Microsoft’s web page is actually a downloader. When you run it, it will download the actual IDE from Microsoft. We also recommend installing the optional Microsoft MSDN 2008 Express Edition if you can spare 248 megs of hard drive space:
Note: This tutorial was originally written when Microsoft was distributing the 2005 version of Visual C++. Consequently, all references and screenshots are targeted to that version. Running the 2008 version is fine, however, your screens may look slightly different.

MSDN express will give you documentation about C/C++ functions that you will refer to often. If you do not install MSDN Express on your hard drive, then Visual C++ 2005 will use the online version at msdn.microsoft.com/.
The installer will likely ask you to reboot your computer after it has finished downloading the components. When it does, your computer may appear to “hang” temporarily. Don’t panic, it’s just installing stuff. Once you are back into Windows, you may need to run the installer again. Choose the same options, and it will seem like it’s going to download everything again, but it won’t. It will install the program.
Linux or Windows
If you are developing on Linux (or you are developing on Windows but want to write programs that you can easily port to Linux), we recommend Code::Blocks. Code::Blocks is a free, open source, cross-platform IDE that will run on both Linux and Windows.
As of the time of this writing, Code::Blocks is in heavy development towards version 2 and is in a bit of disarray. Currently, the best place to download Code::Blocks is here.
Windows users, make sure to get the version “With contrib plugins – With MinGW bundled”.
If you are running Linux and your distribution is listed as not supported, you can look here. Check the various threads entitled “The xxx build is out.”, and you will be able to find Ubuntu, Suse, and Fedora Core 4 builds. If the build you want says (not yet), try an older thread. If this information has become out of date, try the general Code::Blocks website.
Alternately, some people prefer to use Bloodshed’s Dev-C++, which also runs on both Windows and Linux.
Mac OSX
Mac users can use Xcode if it is available to you, or Eclipse. Eclipse is not set up to use C++ by default, and you will need to install the optional C++ components.
Moving on
Once your IDE is installed (which is one of the hardest things this tutorial will ask you to do), you are ready to write your first program!
0.6 — Compiling your first program
|
Index
|
0.4 — Introduction to development
|
0.6 — Compiling your first program
Index
0.4 — Introduction to development
I faced problems installing code::blocks and Microsoft’s IDE is more than 800 MB in size(so i cant download it)
I am happy with Dev C++.
you dont need an IDE justa compiler and your set
although IDE’s are easier they can be a bit of a hassle but its all up to you i prefer no IDE because i like command lines but if your just starting i would use an IDE
Me too.But not for serious product code.
I will be installing XCode on my Mac ASAP!
(does anyone read these things?)
I read all the comments. :)
I just want to let you know that I find the information you have provided easy to understand. I discovered your website when I was desperate! Keep up the great work.
Excellent !
There are some comments here that dont deserve to be dignified with being read, let an answer from Alex.
I have been looking for a site that taught C++ usuing MS Visual Studio. LearnCPP.com pops up when searching for C++ tutorials but didnt pop up for me when I was searching for C++ tutorials usuing MS Visual Studio. I am gald I read this far, because now I am excited. The site seems very upto date in content so far and is usuing the compiler and environment I was looking for.
Is that OK to install C++ Visual 2008 instead of 2005 which not available on microsoft site.
Yes, that’s fine. :) Some of the dialogs may look a little different, but all of the code should compile without incident.
Thanks for your help. Your tutriol is very helpful & easy to understand so far …
If anybody reading this is a linux newb like me using mandriva. You can just
as root and then run it by typing codeblocks.
And thanks for this awsome guide
I installed Microsoft Visual Studio Express 2008 and have tried the hello world program in this tutorial, but it dosent work, it says the system cannot find the path specified, (when i try to run it with ctrl f 5) also before that when i click on build solution it says the file is out of date, it also says that when i try to write “game” in the microsoft tutorial. Do you have any suggestions? Thanks!
I am not sure what would cause this. Sounds like some of your paths are set incorrectly. Does it compile and not execute? Or does it not even compile?
Wow, this site is so amazing thus far, and I’m sure will continue to amaze me! I just had a question!
In this tutorial, you suggest the download of Microsoft’s Visual C++ 2005 Express Edition for the window users, but what about this new 2008 version? Would it all work out the same way?
Thank you for putting this site up.
Yes, the 2008 version is fine.
Great job, I love the site so far. I’m hoping the next tutorials will be as easy to understand as these.
Another great section of the tutorial. Thanks for the feedback on which IDE is most helpful.
Whew! It took about an hour but I finally downloaded Xcode. I can’t wait to make my first program!
when i downloaded the Microsoft download thing it was ok but i opened it it kept saying lost connection to the server so i got bloodshed DEV-c++ instead i was wondering if this was the best choice besides Code::Blocks.
Thank you, thank you, thank you for this. Most of the tutorials that I’d found up until now assumed that people had a bit of experience. Even the “No Code-Writing Necessary” software that I tried was too complicated for me. So I’m back to the basics and I’m thrilled to have found your site. I am downloading Microsoft Visual C++ 2008 as we speak and I was wondering about the poster who said it was 800MB? The version I’m downloading is only 92MB. Am I doing something wrong?
Thanks again.
I got error message when I build the project.
I installed code::block in Fedora 8, and I can compile the main.cpp with command line.
g++ -g -Wall main.cpp
This will generate a.out file.
“helloworld – Debug” uses an invalid compiler. Skipping…
Nothing to be done.
I actually am having same problem as you had.
Did you find how to fix this?
If you did, please help me out.
So is Eclipse ok?
Yes, there is a C++ version of Eclipse. When I tried it a few years ago, I found it hard to use, but it’s possible it’s gotten better since then, as Eclipse is quite popular.
sure is ok, it’s quite professional, but is way too slow comparing to dev++ or code::blocks, but if that doesn’t mind you feel free to try NetBeans is way friendlyer in C++ comparing to eclipse.
Does anyone know why Code::Blocks is giving this error message?
The same thing happens on my other PC, not my laptop though, it works fine there…
does anyone know how to solve the problem?
Damn, will have to wait to get home before i can get the IDE, can’t use up all the companies cap :)
Alex, I have used this site for a few months now (great tutorial!) and have just now registered to ask this. I can’t seem to find anything on how to turn on line numbering. Every example you have has numbers in it and it would be helpful for me to start using it. I’ve looked everywhere though! I am using the suggested Microsoft Visual C++ 2008 Express. This seemed like the best place to post this so I hope you will find it and help me out. Thanks!
Sorry it took me so long to respond. The line numbering is done on this website by a special plugin. I think you can get line numbers in MS C++ 2005 by going to Tools->Options, open Text Editor, select “All languages”, and check the line numbers checkbox.
Not sure whether it was moved in C++ 2008 or not.
The line numbering is turned on exactly the same way in the 2008 version.
Thanks for a great tutorial. At last, a tutorial that treats you like a beginner not an idiot.
I liked Michael’s comment about bloodshed DEV-c++. Every computer on my school campus has Bloodshed DEV-c++ installed on it. It seems to be very popular for both Windows and Linix (I think it can even be used on Macs but I am not sure). It looks like it is the new hit program to work with C++
I found this site very helpful, in terms of basics and advanced concepts too.
thanks alot for this. waiting for more add ons.
can u please provide some guide for coding in Gcc compilers.
hi i am downloading the 2008 microsoft version of c++ express its 96 mb is it the right thing ?and do i require some sql thing
Microsoft C++ is big because it has lots of features (most of which you will never use). You don’t need any SQL stuff.
I prefer Microsoft Visual Studio 6.0 IDE.
i’m using Visual Studio 6.0 and I never had problems so far. It’s very comfortable and reliable. Works with Windows 95/98/2000/Me/XP.
I used Visual Studio 6.0 for a long time. Was a good product. The downsides of it are:
1) It’s not free
2) It only has a partial template implementation, so a lot of modern template code doesn’t work on it.
Is there a big difference between Microsoft’s Visual C++ 2005 and Visual Studio 2008 (C++ supporter)?
I Like these tutorials, usually i end up sitting at my computer, staring at huge (and i mean HUGE!) mindless scripts and texts which never really work
at least this tells you what you need to do accurately, rather than placing you in the middle of something completely alien to you.
And in answer to your question Noha, the writer of this stated the only difference is the window organisation (the screen of the program is arranged differently)
Oh the writer of this is Alex- i never noticed the name at the top sorry :P
Nice that these things are free. Probably the first tutorial I will ever follow where it feels like if I have the same program xD
Does Visual 2008 work on Vista, because it won’t open
I’m having trouble with the installation.
After the downloading has finished & has reached halfway installing “.net framework 3.5″, it just stops installing any further. It just stays on that place.
Plz help.
Excellent stuff !
For the very beginning, to test simple code, I would also recommend Geany editor. It runs under Win and Linux. It’s got an in-built terminal. I use it for scripting and testing my scripts in PHP and Perl under Linux.
Write some code, hit F8 (compile) then F9 (build) and then F5 (execute). In two seconds you can see your output in the terminal. Change your code and hit the function keys again. In a minute you can test your code a couple of times.
Linux users have to install g++
Of course, install Code::Blocks under Linux too :-)
Im a hands on type of guy so is there a version of this with hands on or can i do this hands on?
Hello, for slackware users, i currently use slackware 13, you may install Code::Blocks from here http://slackbuilds.org/repository/13.0/development/codeblocks/ and dependences from slackbuilds.org too. Geany (Recommended) is simple but fast for short examples, you can download from slackbuilds.org. I dont recommend Bloodshed DEV-c++ for windows is too old instead you can use wxDev-C++ download here http://wxdsgn.sourceforge.net. Bye