[C ++ exploration journey] Part 1 Lesson 2: necessary software for C ++ programming Part 1

Source: Internet
Author: User

[C ++ exploration journey] Part 1 Lesson 2: necessary software for C ++ programming Part 1

Bytes


Introduction

1. Part 1 Lesson 2:Necessary software for C ++ Programming

2. Part 1 Lesson 3: First C ++ Program


Necessary software for C ++ Programming


After the last lesson, are you ready for a big fight.


In this lesson, we prepare for C ++ development.



Essential programming tools


According to you, what software is necessary for programming? If you take the last lesson seriously, you can say at least one.


By the way, it is the compiler. This important program can convert your source code (instructions written in advanced languages such as C Language) into binary codes that computers can understand (only containing 0 and 1, like 01100110001111011101010 ...).


In the previous lesson, we also mentioned that each high-level language has a corresponding compiler (of course, for an interpreted language like Python, you do not need to compile it ), there are many compilers in C ++ alone. Commonly used include G ++ (gnu c ++ Compiler. GNU is an internationally renowned Free Software Foundation. GNU is the recursive abbreviation of "GNU is Not Unix" (GNU is Not Unix). Foreigners are always so naughty, like programming, for example, recursion of "Linux Is Not Unix" (Linux Is Not Unix. It is especially fun to use the names or icons of many animals ).



What tools do we need besides the compiler?


The following lists the basic programming tools:


  • Text Editor: A tool used to write source code. Theoretically, Windows OS notepad or Linux VI editor can be used as a text editor. However, it is better to use some more advanced text editors, such as supporting code highlighting to facilitate inter-code jump. Personally, the recommended text editor is Emacs, which is really strong, cross-platform (such as Apple Mac, Windows, and Linux), customizable, combinations of shortcut keys, sending and receiving emails, watching videos, and Browsing webpages, browsing PDF, you can't do it, just think of it (slightly exaggerated ...), this allows you to edit code very efficiently. I used VIM before and it was quite good. But I used Emacs later, and I still prefer Emacs. Of course, this is wise. There is also a text editor: Notepad ++ is also quite good. After configuring and installing some plug-ins, it can be very powerful, but it seems that there is no Apple computer version.


  • Compiler: You have already mentioned that it is used to convert (or compile) your source code into a binary code.


  • Debugger: Debugger, a tool used to track and discover errors in a program. Here is a new term called Debug ). Bug is an English bug. The bug means that de is a prefix in English that indicates "Separation and removal". So Debug means removing the bug. Generally, errors or defects in a program are called bugs, which are said to be due to the legend of female programmer Grace Hopper. hope) one time I found a moth in the MARK II computer, which was a very large computer in the early days, the moth caused the computer to crash (between the relays in the computer). Hope clipped the moth with tweezers and pasted it on his notebook with transparent adhesive tape, and indicate "the first instance for discovering bugs ". Since then, people have followed this title and used debug to indicate the behavior of eliminating program errors. Now Hope's notebook, along with the cute moth, is displayed in the American Museum of History.


Hope's notebook and glorious moth loaded into history


Of course, if you are adventurous and want to challenge yourself, you don't need a debugger (you can also find the error by yourself through some tips ). However, I think you usually need a debugger.


Therefore, we have two options:

  • Use the text editor, compiler, and debugger tools separately. Although complicated, it works. Especially in Linux, many programmers still like to program in this way. It may not be installation, but it is feel, which is cool.

  • Use a software that integrates the functions of these three tools. This kind of software is called Integrated Development Environment (IDE ).


In the beginning, it may be difficult for you to decide which one to use? Even if you choose to use IDE, you will also find out which IDE to use. In fact, we can be certain that no matter which tool you choose, you can write the program you want. It's just efficiency. personal habits are different from specific platform requirements.


For more information, see:

If you are new to the C ++ language, try to learn C ++ programming in the Linux Command Line. In the beginning, do not rely too much on IDE.


Because IDE is doing a great job, there are prompts, and the code is automatically supplemented to help you add code automatically, you can't learn much, but you can't remember it. When the programming level is better, it is not too late to use IDE. At that time, IDE can improve your programming efficiency. It is a good choice to use emacs or vim to compile C ++ language, G ++ to compile C ++ language, and GDB (GNU Debugger) to debug C ++ language.


Of course, we will spend a lot of time introducing several commonly used ides.


Select your IDE


We think it is necessary to show you several of the most famous ides, which are free of charge (only buy right, not choose expensive)


  • Code: Blocks: A favorite IDE, which is free, open-source, and cross-platform.In subsequent courses, we will use Code: Blocks for development.Because the Code: Blocks development environment is set up too quickly and does not require any configuration.

    It can run on Mac, Windows, Linux, and many other operating systems.


  • Visual Studio: the basic version is charged. Fortunately, a Visual Studio Express version is free of charge. The VS function is complete and the debugger is powerful.

    It can only run on Windows.


  • Xcode: as Apple's home IDE, I have to say that Xcode is really great. It can be used to develop basic small programs, iPhone and iPad apps (super fast simulator), smart watch apps, and other 3D engines such as Unity to compile games.

    It can only run on Apple Mac OS X.



Code: Blocks


Code: Blocks is a very good IDE, but currently only the English version is available. Of course, there are also Chinese versions on the Internet. However, since learning programming, I should try to turn off the English language, it does not need to be too good at English. After all, some translations of the Chinese version are not in place and may affect the usage. In addition, good programming resources are basically in English.


Download Code: Blocks


Go to Code: Blocks official download page: http://www.codeblocks.org/downloads/binaries

  • For Windows users, download the. exe file,Please note that you need to download the one with the mingw name(Codeblocks-13.12mingw-setup.exe), because it will be very troublesome if the versions without mingw do not contain the compiler.

  • For Linux users, download the version corresponding to your operating system

  • Apple Mac users download CodeBlocks-13.12-mac.zip



Install and run the Code: Blocks


Code: the installation of Blocks is too simple, it is no difference with the installation of QQ, it is good to default all the way to the end.

After the installation is complete, double-click to run it. You can see the interface shown in figure



Marked with four areas:

  1. Toolbar: There are many buttons, but there are only a few buttons that we often use.

  2. Project file list area: All files of your project are displayed in the left column.

  3. Main Interface: code writing place

  4. Notification bar: you will see running errors, compilation problems, and so on.


How can I create a basic console application in C ++?


First, go to the menu and choose File> New> Project. The following window is displayed:



As you can see, Code: Blocks supports many program types. These program types use different libraries, such as SDL (developing 2D programs), OpenGL (developing 3D programs ), qt and wxWidgets.


Currently, many of these icons are just nice-looking, because you have not installed the corresponding library, and none of them can be used. We will develop games based on the SDL library in subsequent courses. For the moment, we only use the most basic Console application (the Console application, in simple words, will pop up a box showing the program running results ).


Select Console application and click Go to next step.



Enter the name of the Project you want to create in "Project Title". We enter the famous HelloWorld. "Folder to create project in" is the path for storing the selected project.

Click Next to Next,



Here we do not need to change anything, the default is good. Click Finish to complete the configuration. Code: Blocks will create your first project.



Visual Studio


Download Visual Studio Express, go to official download page http://www.visualstudio.com/products/visual-studio-express-vs


Select a version suitable for your operating system to download.


Because the editor edited the article on the Apple computer, I will not do more demonstration. Please refer to the installation and use of text tutorials on the Internet.


After installation and running, the layout should be similar to Code: Blocks:




Xcode


There are many ides in Mac operating systems, but Xcode is a favorite of Apple users.

Not all Apple users are programmers, So Apple didn't pre-install Xcode in Mac systems. You need to download Xcode from Mac App Store (App Store) (you need an apple account, no one can be registered ).


It is easy to Install. You only need to search for Xcode in App Store and then click Install to Install it in the application. Run Xcode



Select Create a new Xcode project (Create a new Xcode project). The following window is displayed.



Choose OS X-> Application-> Command Line Tool and click Next to Next.




Enter the Project Name in the Project Name, And we enter HelloWorld. Select the C ++ Language as the Language. Click Next to select the path of the project folder. Click Finish.





After the project is opened, click the triangle button to run. The output is Hello World!




Summary


  1. A program needs to be compiled from the beginning to run. Generally, three tools are required: Text Editor, compiler, and debugger. (Of course, it does not need to be compiled for an interpreted language like Python)

  2. We can use these three tools separately to complete the task. But it is more convenient to use IDE (integrated development environment, mixed with the three) for development.

  3. Code: Blocks, Visual Studio (or Visual C ++), Xcode is the most famous IDE, and of course there are many excellent IDES (such as Eclipse. IDE is just a tool.



Part 1 Lesson 3 advance notice


Today's class is here. Come on!

In the next lesson, we will learn:The first C ++ Program



Programmer Alliance Community

Currently, there isGroupAnd oneQQ Group(More than 160 people in the group and more than 530 people in the QQ Group). Anyone interested in programming can add them. You can exchange, learn, interact, and discuss the source code of the program, programming Q &.


Group (programmer Alliance). If you want to add a group, please send a private message to me. (if the number of groups exceeds 100, you cannot scan the QR code to join the group. You can only send a private message to me. Thank you)


QQ group:413981577(1000 people)


There are many programming books PDF and other materials in the QQ group file. Scan the following QR code and add QQ:



We have also set up a public Baidu cloud disk with 2 TB capacity. There are already many excellent programming resources that you can upload. The link is sent after the group is added.


Baidu Post Bar 【Programmer Alliance] You are welcome to join, exchange programming, discuss code, and share resources. There are already many topics. This is a small Editor.

Http://tieba.baidu.com/f? Kw = % E7 % A8 % 8B % E5 % BA % 8F % E5 % 91% 98% E8 % 81% 94% E7 % 9B % 9F & ie = UTF-8

Click 【Read original] To enter the [programmer Alliance] Baidu Post Bar


Programmer AllianceMicro-communityTo facilitate questions and interactions. Take a look.

The micro-community address and QR Code are as follows:

Http://m.wsq.qq.com/264152148


Thank you!



Programmer Alliance public account * if you think this article is good, please click "·" in the upper right corner of the screen to "share to a circle of friends" or "send to a friend"

* New friends should follow the "Programmer alliance" Search Public AccountProgrammerleleague

Small No.: frogoscar

Xiaobian QQ: 379641629

Alimail: enmingx@gmail.com

Programmer Alliance QQ group: 413981577

Programmer Alliance group: Add me first


Some friends reported that reading articles on mobile phones was too tired, but they could be viewed on a browser webpage:

Method 1. Click the "·" button in the upper-right corner of the screen, select "Copy link", paste the link to your browser, or send it to yourself by email, you can open it in your computer's browser.



Method 2. Toutiao.comWww.toutiao.com, Search for my self-Media"Programmer Alliance", There are articles, you can also directly into this link: http://www.toutiao.com/m3750422747/


Method 3. My 51CTO blog, CSDN blog, and blog garden links (all articles are on top)
Http://4526621.blog.51cto.com

Http://blog.csdn.net/frogoscar

Www.cnblogs.com/frogoscar


How to view all articles:

Click"View Public Accounts", And then click"View historical messages"





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.