C++ environment settings


Local environment settings

If you want to set up the C++ language environment, you need to ensure that the following two software are available on your computer, a text editor and a C++ compiler.

Text Editor

This will be used to enter your program. Text editors include Windows Notepad, OS Edit command, Brief, Epsilon, EMACS, and vim/vi.

The name and version of the text editor may vary on different operating systems. For example, Notepad is commonly used on Windows operating systems, and vim/vi is available on Windows and Linux/UNIX operating systems.

Files created through an editor are often called source files, which contain program source code. Source files for C++ programs typically have the extension .cpp, .cp, or .c.

Before you start programming, make sure you have a text editor and are experienced enough to write a computer program, then save it in a file, compile and execute it.

C++ Compiler

Source code written in source files is human-readable source. It needs to be "compiled" into machine language so that the CPU can execute the program according to the given instructions.

C++ compiler is used to compile source code into the final executable program.

Most C++ compilers don't care about the source file extension, but if you don't specify an extension, .cpp is used by default.

The most commonly used freely available compiler is GNU's C/C++ compiler, and if you are using HP or Solaris, you can use the compiler on the respective operating system.

The following sections will guide you on how to install the GNU C/C++ compiler on different operating systems. C/C++ is also mentioned here, mainly because GNU's gcc compiler is suitable for the C and C++ programming languages.

Installing the GNU C/C++ compiler

Installation on UNIX/Linux

If you are using Linux or UNIX, please use the command Use the following command to check whether GCC is installed on your system:

$ g++ -v

If the GNU compiler is already installed on your computer, the following message will be displayed:

Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr .......
Thread model: posix
gcc version 4.1.2 20080704 (Red Hat 4.1.2-46)

If not To install GCC, follow the detailed instructions at http://gcc.gnu.org/install/ to install GCC.

Installation on Mac OS X

If you are using Mac OS X, the fastest way to obtain GCC is to download the Xcode development environment from Apple's website and follow the installation instructions Install. Once Xcode is installed, you can use the GNU compiler.

Xcode is currently available for download at developer.apple.com/technologies/tools/.

Installation on Windows

In order to install GCC on Windows, you need to install MinGW. In order to install MinGW, please visit the MinGW homepage www.mingw.org, enter the MinGW download page, and download the latest version of the MinGW installer, with the naming format MinGW-<version>.exe.

When installing MinWG, you will need to install at least gcc-core, gcc-g++, binutils, and the MinGW runtime, but usually more will be installed.

Add the bin subdirectory of your MinGW installation to your PATH environment variable so that you can specify these tools by simple names on the command line.

When the installation is complete, you can run gcc, g++, ar, ranlib, dlltool, and some other GNU tools from the Windows command line.