Can be compiled c ++ in Ubuntu

This is a brief introduction to the operation of the GNU C ++ Compiler. It is not an introduction to the language C.. For this I refer to the literature mentioned below. The compilation of C ++ programs for the terminal mode of Linux is discussed. The graphic programming of X-Windows by means of the Qt3 / Qt4 graphics library can be found in the KDE or Qt books in the appendix.

The language C and C ++ are the standard languages ​​in Linux, although practically every modern computer language is available in Linux. UNIX and C are closely related. The C language was invented by Kerningham and Ritchie in 1972 specifically for the development of UNIX. It has developed in several stages since then. The old Kerningham / Ritchie standard is practically no longer used because it can lead to very illegible programs. Anyone who programs in C today should adhere to the ANSI-C standard.

The C ++ language was developed by Bjaarne Stroustrup in 1985. It too has gone through several stages of evolution to this day. Today the ANSI C ++ 3.0 version is the newest standard. C ++ extends the C language to include the concepts of object-oriented programming. These are the formation of classes (data encapsulation), inheritance, polymorphism, the overloading of operators and much more. However, every C ++ compiler can also work as a C compiler, which means that a migration from C to C ++ is possible.

Linux itself is not written in C ++, but in C with smaller assembler parts. C is ideal for developing operating systems, as it can generate highly optimized code without necessarily having to resort to assembler. The C code is very portable, so that Linux is available today on practically every type of CPU. The C ++ language is used, for example, in the Qt graphics library.


The compiler gcc 4.2.1



using namespace std;


I don't want to explain the program explicitly here. You can learn C or C ++ in our LINUX group. Simply enter the source code and save it under versuch.cpp.


1st translation attempt

Enter the command:

2. Translation attempt

Enter the command:





Generate debugable code

A machine program does not inherently contain any debugable code. Unless you love uncommented machine code. To debug C ++ programs, the C ++ compiler must append a symbol table with variables and line information to the code.

With the compiler option -G we tell the GNU compiler to append this symbol table to the code.

Enter the command:

Compiler options

The GNU C ++ compilers know a huge number of compiler options, one could write an entire book about them. I would like to name just a few:



Graphic programming under Linux:

C ++ GUI programming with Qt3
Jasmin Blanchette (English)
Prentice Hall 2004
ISBN 0-13124072-2
(very current with Qt 3.2)

The Qt book
Helmut Herold
SuSE Press 2001
ISBN 3-934678-76-9

KDE2 programming
David Sweet
Markt + Technik Verlag 2001
ISBN 3-8272-5980-0

KDE and Qt programming
2nd Edition
Burckhard Lehner
Addison-Wesley-Verlag 2001
ISBN 3-8273-1477-1

Programming with Qt 2nd edition
Kalle Dalheimer
O'Reilly Publishing 2001
ISBN 3-89721-130-0

KDE programming:
Uwe Thiem
Franzis publishing house
ISBN 3-7723-6124-2

C / C ++ programming:

C programming under Linux
Helmut Herold
SuSE Press 2002
ISBN 3-935922-08-6

Now I'm learning C ++
Jesse Liberty
Markt + Technik Verlag 1999
(very nice book for beginners)

C / C ++
New Reference
Dirk Louis
Markt & Technik Verlag
ISBN 3-8272-6121-X
(Reference book C / C ++ syntax)