Before you begin your exploration of the C++ landscape, you must gather some basic supplies: a text editor, a C++ compiler, a linker, and a debugger. You can acquire these tools separately or bundled, possibly as a package deal with an integrated development environment (IDE). Options abound, regardless of your platform, operating system, and budget.
If you are taking a class, the teacher will provide the tools or dictate which tools to use. If you are working at an organization that already uses C++, you probably want to use its tools, so you can become familiar with them and their proper use. If you have to acquire your own tools, check out this books web site, http://cpphelp.com/exploring/ . Tool versions and quality change too rapidly to provide details in print form, so you can find up-to-date suggestions on the web site. The following section gives some general advice.
Rays Recommendations
C++ is one of the most widely used programming languages in the world; it is second only to C (depending on how you measure widely used). Therefore, C++ tools abound for many hardware and software environments and at a wide variety of price points.
You can choose command-line tools, which are especially popular in UNIX and UNIX-like environments, or you can opt for an IDE, which bundles all the tools into a single graphical user interface (GUI). Choose whichever style you find most comfortable. Your programs wont care what tools you use to edit, compile, and link them.
Microsoft Windows
If you are working with Microsoft Windows, I recommend Microsofts Visual Studio (be sure that you have a current release). As I write this, the current release is Visual Studio 2012. If you want a no-cost option, download Visual Studio Express from Microsofts web site (find a current link at http://cpphelp.com ), or for an open-source solution, download MinGW, which is a port of the popular GNU compiler to Windows.
Note that C++/CLI is not the same as C++. It is a language that Microsoft invented to help integrate C++ into the .NET environment. Thats why they chose a name that incorporates C++, just as the name C++ derives from the name C. Just as C++ is a distinct language from C, so is C++/CLI a distinct language from C++. This book covers standard C++ and nothing else. If you decide to use Visual Studio, take care that you work with C++, not C++/CLI or Managed C++ (the predecessor to C++/CLI).
Visual Studio includes a number of doodads, froufrous, and whatnots that are unimportant for your core task of learning C++. Perhaps you will have to use ATL, MFC, or .NET for your job, but for now, you can ignore all that. All you need is the C++ compiler and standard library.
If you prefer a free (as in speech) solution, the GNU compiler collection is available on Windows. Choose the Cygwin distribution, which includes a nearly complete UNIX-like environment, or MinGW, which is much smaller and might be easier to manage. In both cases, you get a good C++ compiler and library. This books web site ( www.apress.com/9781430261933 ) has links with helpful hints for installing and using these tools.
Macintosh OS X
Apple provides a no-cost IDE, call Xcode (see the link at http://cphelp.com ), which includes the clang C++ compiler from the LLVM Compiler Infrastructure project. This is an excellent C++ compiler, and Apple bundles an excellent C++ standard library with it.
Everyone Else
I recommend the GNU compiler collection (GCC). The C++ compiler is called g++. Linux and BSD distributions typically come with the entire GCC suite, including g++, but you might have to install the necessary developer packages. Be sure you have a recent release.
Some hardware vendors (Oracle, HP, etc.) offer a commercial compiler specifically for their hardware. This compiler might offer better optimization than GCC but might not conform to the C++ standard as well as GCC. At least while you work through the exercises in this book, I recommend GCC. If you already have the vendors compiler installed, and you dont want to bother installing yet another compiler, go ahead and use the vendors compiler. However, if it ever trips over an example in this book, be prepared to install GCC.
If you are using an Intel hardware platform, Intels compiler is excellent and available at no cost for noncommercial use. Visit the books web site for a current link.
If you want to use an IDE, choose from Eclipse, NetBeans, KDevelop, Anjuta, and others (go to http://cpphelp.com for an up-to-date list).
Read the Documentation
Now that you have your tools, take some time to read the product documentationespecially the Getting Started section. Really, I mean it. Look for tutorials and other quick introductions that will help you get up to speed with your tools. If you are using an IDE, you especially need to know how to create simple command-line projects.
IDEs typically require you to create a project, workspace, or some other envelope, or wrapper, before you can actually write a C++ program. You must know how to do this, and I cant help you, because every IDE is different. If you have a choice of project templates, choose console, command-line, terminal, C++ Tool, or some project with a similar name.
How long did it take you to read the documentation for your compiler and other tools? ________________
Was that too much time, too little time, or just right? ________________
The C++ language is subject to an international standard. Every compiler (more or less) adheres to that standard but also throws in some nonstandard extras. These extras can be usefuleven necessaryfor certain projects, but for this book, you have to make sure you use only standard C++. Most compilers can turn off their extensions. Even if you hadnt read the documentation before, do so now, to find out which options you need to enable you to compile standard C++ and only standard C++.
Write down the options, for future reference.
_____________________________________________________________
_____________________________________________________________
_____________________________________________________________
You may have missed some of the options; they can be obscure. To help you, Table lists the command-line compiler options you need for Microsoft Visual C++, g++, and clang. This books web site has suggestions for some other popular compilers. If you are using an IDE, look through the project options or properties to find the equivalents.
Table 1-1.
Compiler Options for Standard C++
Compiler | Options |
---|
Visual C++ command line | /EHsc /Za |
Visual C++ IDE | Enable C++ exceptions, disable language extensions |
g++ | -pedantic -std=c++11 |
clang/llvm | -pedantic -std=c++11 |