C ++ programming in Linux

Source: Internet
Author: User

C ++ programming in Linux

C ++ is a powerful and widely used computer language. In terms of application fields, it is almost ubiquitous, because C ++ exists in operating systems, popular programs are second only to C and Java. C has a natural kinship with C ++.

I have been engaged in C ++ development for nearly two years. Although all products developed are cross-platform, however, my personal direct access to programming projects is more focused on the Windows platform (at least the development environment is more on the Windows platform, I have also written a blog post on "show you how to use Visual Studio"). Now I want to develop a project independently, or a cross-platform project, it is necessary to have a systematic learning and understanding of C ++ programming in Linux.

This series records some summary and experiences of C ++ learning on the Linux platform. Hope to learn and grow with everyone!

Before programming C ++ in Linux, we should first understand several important tools and concepts:

GUN

For programming in Linux, GNU is a concept that you can never go around, because you can see it everywhere. What is it?
GNU is short for GNU's Not Unix, meaning that GNU is Not Unix. So what is it? In fact, it has multiple meanings:

GUN Project

In 1984, Richard Stallman started the GNU project,This project aims to create a Free and open UNIX operating system ).But it's easy to create an operating system! In addition, at that time, GNU only had stoman alone, which was too troublesome but could not be abandoned. As a result, Shi Toman did the opposite: "Since the operating system is too complex, I should first write the small programs that can run on Unix. Is that all right ?" Based on this idea, Shi Toman began to refer to existing software on Unix, develop software with the same function based on the role of the software, and open source it. More and more people will know about the free and easy-to-use GUN software, and the performance of the paid patents will not be much inferior. the more people who use GUN software, the higher the GNU project will gradually become known.

For the purpose of this plan, he began to use the software running on the original Unix and wrote software with similar functions as the original patented Unix software. However, no matter what software, it must be compiled into a binary file before it can be executed. Therefore, he began to write a C language compiler, that is now the well-known gnu c (gcc )! This point is very important! This is because there are many C language compiler versions, but they are all patented software. If the C compiler he wrote is good enough and the effect is good, it will greatly make the GNU program appear in front of everyone!

GUN Free Software agreement

The GPL Protocol refersGeneral Public License(General Public License, GPL ). Since the software developed by the GNU project is open-source free software, it may be stolen by others and registered to become a patented software. In order to solve this problem, Shi Toman and his lawyers drafted a famousGeneral Public License AgreementYou can see the declaration of this Protocol at the beginning of every file of the GNU software source code (such as. h and. cpp), for example:

/* * Copyright (C) 2004-2010 Geometer Plus 
  
    * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA. */
  

For more information about the GPL protocol, see http://www.gnu.org/licenses/gpl-3.0.en.html.
The GPL protocol is described as follows:
You can --
Obtain the software source code:You can execute the Free Software of the GPL protocol as needed;
Copy:You can freely copy the software;
Modify:You can modify the obtained source code to suit your work;
Reissue:You can release the modified programs again without conflict with the original writers;
Feedback:You can give back the modified program to the society!
You cannot --
Modify authorization:You cannot cancel the GPL authorization of a GPL-authorized free software after you modify it;
Simple sales:You cannot simply sell free software;

Free software developed by GUN

As mentioned above, stoman started the GNU project to develop a large number of Free Software. With the successful development and widespread use of these software, GNU's familiarity has become wider and wider. Well-Known Free Software widely used now includes:
Emacs
GCC (GNU Compiler Collection C program Compiler), G ++ (C ++ Compiler)
Gun c Library (GLIBC)
Bash Shell

GCC and G ++

FirstGCCIt refers to the GNU Compiler Collection, which is a Collection of GNU compilers. It contains a variety of compilers and related tools, such as gcc and g ++. GCC is the integration (or integration) Release of compilers in multiple major programming languages. These programming languages currently include C, C ++, Objective-C, Objective-C ++, Java, Fortran, and Ada. See Using the GNU Compiler Collection

GccIs the gnu c Compiler (gnu c Compiler) and is part of the GNU Compiler Collection;
G ++Is the gnu c ++ Compiler (gnu c ++ Compiler) and part of the GNU Compiler Collection;

GDB

GDB is a debugging program (GNU Debugger) of the GNU Project. It allows you to view the specific execution logic of a program during execution, or what the program executes when it crashes.
GDB can do four main tasks (and other functions supported by it) to help you discover program bugs:
1. Start a program and specify anything that may affect its behavior;
2. pause your program with the specified conditions;
3. Check what happened when the program is stopped;
4. Change the variables or data in your program so that you can test the factors that affect your program bug and learn more.

GDB can debug programs written in the following programming languages: Ada, C, C ++, Objective-C, Pascal, etc. These programs may be executed on the same machine (local debugging ), it may also be executed on different machines (remote debugging). GDB can run on favorite Unix and Microsoft Windows.
See The GNU Project Debugger.

Makefile

Makefile is the rule for program compilation. makefile records the compilation rules of the entire project (such as the compilation sequence and dependency of the source file) and uses the make tool for compilation. Make compiles the source code into two files according to the rules defined by makefile. In cross-platform (especially in Unix-like systems) programs, makefile is usually used for compilation.

 

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.