The settings for the C++ environment


May 11, 2021 16:00 C++


Table of contents


The settings for the C++ environment

Local environment settings

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

The 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 from operating system to operating system. For example, Notepad is typically used on Windows operating systems, vim/vi is available on Windows and Linux/UNIX operating systems.

Files created through the editor are often referred to as source files, which contain program source code. The source files of the C++ program typically use the extension .cpp, .cp, or .c.

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

The C++ compiler

The source code written in the source file is a human readable source. It needs to be "compiled" into a machine language so that the CPU can execute programs on a given instruction.

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

Most C++ compilers don't care about the extension of the source file, but if you don't specify an extension, you're using the .cpp.

The most commonly used free-to-use compiler is GNU's C/C?compiler, and if you're using HP or Solaris, you can use the compiler on your operating system.

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

Install GNU's C/C?compiler

Installation on UNIX/Linux

If you are using Linux or UNIX, use the following commands on the command line to check if GCC is installed on your system:

$ g++ -v

If you already have the GNU compiler installed on your computer, the following message appears:

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 the GCC is not installed, follow the http://gcc.gnu.org/install/ detailed instructions on the document.

Installation on Mac OS X

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

Xcode is currently available for download developer.apple.com/technologies/tools/ on the website.

Installation on Windows

In order to install GCC on Windows, you need to install MinGW. To install MinGW, visit MinGW's home page, www.mingw.org, and go to the MinGW download page to download the latest version of the MinGW installer, named MinGW-lt;version.exe.

When you install MinWG, you need to install at least gcc-core, gcc-g+, binutils, and MinGW runtime, but in general more items are installed.

Add the bin subdirectors of the MinGW you installed to your PATH environment variables so that you can specify these tools by a simple name 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.