C + + Primer Plus Learning Note--c++ program creation to run the entire process

Source: Internet
Author: User

When you write a C + +, how do you make it work? The specific steps depend on your computer environment and the C + + compiler you use, but it is broadly as follows:

1. Write the program using a text editor and save it to a file, which is the source code of the program.

2. Compile the source code. This means running a program that translates the source code into the internal language that the host is using-machine language. The file that contains the translated program is the object code of the program.

3. Strong target code is connected to other code. For example, C + + programs typically use libraries. The C + + library contains target code for a series of computer courses called functions that perform tasks such as displaying information on the screen or calculating the square root. A link is a combination of the target code of the target function of the target code with the function used and some standard startup code, which generates the runtime version of the program. The files that contain the final product are called executable code.

The procedures in this book are generic and can be run in any system that supports c++98, but the 18th chapter requires the system to support C++11. During the writing of this book, some compilers require you to use specific tags to support some of the c++11 features. For example, starting with version 4.3, g++ requires that you use the tag-std=c++0x when you mutate a source code file:

g++-std=c++0x Use_auto.cpp

Steps:

1. Create a source code file

Table 1.1 Extension of source code files

/tr> tr> tr>

C + + implementation

Source code file suffix name

UNIX

C, CC, CXX, c

GNU C + +

C, CC, CXX, CPP, C + +

Digital Mars

CPP, cxx

Borland C + +

CPP

Watcom

CPP

Microsoft Visual C + +

CPP, CXX, CC

Freestyle Code Warrior

CP, CPP, CC, CXX, C + +

2. Compiling and linking

1.Unix Compiling and linking

......

2.Linux Compiling and linking

The most common compiler used in Linux is g++.

The following command generates the executable file a.out:

g++ Spiffy.cxx

Some versions may require links to C + + libraries:

g++ spiffy.cxx-lg++

To compile multiple source files, simply place them all on the command line:

g++ My.cxx Precious.cxx

This will generate a copy of the executable file named A.out and the two target code files my.o and PRECIOUS.O. If you subsequently modify one of the source code files, such as My.cxx, you can recompile using MY.CXX and PRECIOUS.O:

g++ My.cxx PRECIOUS.O

3.Windows command-line compiler

......

4.Windows compiler

......

C + + on 5.Macintosh

C + + Primer Plus Learning Note--c++ program creation to run the entire process

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.