Termux Work & Programming Language

Termux Work & Programming Language
Learn C++ #02: Preparation to Learn C++ Programming on Linux



In the previous article, we talked about C.


For those of you who have not read it, I recommend reading it before following this tutorial.


Please open: “C++ Programming Language Introduction for Beginners”


After that, we can further prepare the tool to learn C++ on Linux.


Farmer Code


 Ahmad Muhardian 29 Sep 2017


Learn C++ #02: Preparation to Learn C++ Programming on Linux


#C++



In the previous article, we talked about C.


For those of you who have not read it, I recommend reading it before following this tutorial.


Please open: “C++ Programming Language Introduction for Beginners”


After that, we can further prepare the tool to learn C++ on Linux.


Preparation to learn C++ on Linux


Basically we only need two tools, namely: text editor and compiler.


Text editor is a program used to write C++ program code…


…A compiler is a program used to translate the C language into machine language so that it can be understood by the computer.



C++ programming is done also using IDE (Integreted Development Environment).


IDE is a special text editor in which there is already a compiler.


We'll talk more about this later…



Text Editor



There are many text editor options that we can use to write C programs.


There is Notepad, Notepad++, Gedit, Geany, Mousepad, Kate, Atom, VS Code, Sublime Text, etc.


Choose a text editor that you like and can use.


Text Atomic Editor for Writing C Programs


I assume you have provided the text editor. If not, please install it first.


 Ahmad Muhardian 29 Sep 2017


Learn C++ #02: Preparation to Learn C++ Programming on Linux


#C++



In the previous article, we talked about C.


For those of you who have not read it, I recommend reading it before following this tutorial.


Please open: “C++ Programming Language Introduction for Beginners”


After that, we can further prepare the tool to learn C++ on Linux.


Preparation to learn C++ on Linux


Basically we only need two tools, namely: text editor and compiler.


Text editor is a program used to write C++ program code…


…A compiler is a program used to translate the C language into machine language so that it can be understood by the computer.



C++ programming is done also using IDE (Integreted Development Environment).


IDE is a special text editor in which there is already a compiler.


We'll talk more about this later…



Text Editor



There are many text editor options that we can use to write C programs.


There is Notepad, Notepad++, Gedit, Geany, Mousepad, Kate, Atom, VS Code, Sublime Text, etc.


Choose a text editor that you like and can use.


Text Atomic Editor for Writing C Programs


I assume you have provided the text editor. If not, please install it first.


Please read:


[Review] Text editor VS Code


[Review] Text editor Atom


Text Editor is based on text in Linux



Compilers



Compiler is a program that serves to translate C language into machine language, which can be understood by the computer.


There are several compilers that can be used to compile the C++ program.


There are GCC (Gnu Compiler Collection), Clang, Visual C++ 2017, Embarcadero, Oracle Solaris Studio C++ Compiler, and IBM XL C/C++ Compiler.


Please install GCC in Ubuntu with the following command:


sudo apt install gcc # or can also with sudo apt install g++ command


For Windows users, you can use MinGW, Cygwin, or WSL (ubuntu).


After that, try typing g++ - version command to check the installed version.


![![Installed version of G++]](/img/cpp/hello-world/version-cpp.png)


Now all the tools are ready. Next, we can start creating programs.


Creating the First C++ Program


Okay, now we're gonna try to make a Hello World program.


Please open the text editor and type the following code:


#includes


using namespace std;


int main(){ cout << "Hello World!" << endl;


return 0;


}


Save it with the name hello-world.cpp.


After that, open Terminal and go to the directory where the C++ souce code was stored.


For example, I saved it in ~/Desktop/learn-cpp.


cd ~/Desktop/learn-cpp/


After that do compile with the command


g++ hello-world.cpp - o hello-world


Remarks:


g++ is an order to compile C++ program;


hello-world.cpp is a file containing the code of the program C++ (source code);


- is an argument for stating output;


hello-world is the file name of the compilation.


If there is no error, it will generate a new executable file:


We can execute the file with the command:


./hello-world


C++ Programming with Codeblocks


There are many IDE options that can be used to create a C++ program.


There are Codeblocks, Monodevelop, QT Creator, Visual Studio, etc.


In this tutorial we will use Codeblocks, as they are commonly used.


Codeblocks is an IDE specifically designed for C and C++ programming.


Let's try creating a C++ program with Codeblocks.


Please install Codeblocks with the following command:


sudo apt install codeblocks xterm


Wait until the process is complete.


After that, open Codeblocks.


If a window like this appears, just click OK.


This window asks us to determine which compiler to use. Because on our computer already installed GCC, then the only active GCC only.


After that, we can directly create the C++ program by creating a new file.


Click menu File->New->Empty File or press Shift+Ctrl+n.


After that, type the following program code:


#include using namespace std; int main(){ cout << "Hello World!" << endl; return 0; }


Well to compile and run the program, kiata must save it first.


Then to compile, we can click the Build button and to compile and run we can click Build and run


Please click build and run, if it appears like this just click Yes.


The result: then:


Easy no…


But, what exactly happened?


When you press the build & run button, Codeblocks compiles and runs the program.


The compile results can be seen in the directory where the program is stored.


Hold still…


What is Object File?


Object files are files that are generated during compile. It is machine code.


What Next?


We have prepared the tools for C++ programming and tried to create the program first, then what to learn next?


Next you can learn about:


Learn C++ #03: The C++ Basic Syntax You Must Understand!


Any advice and questions?


Please convey through comments


.source of information from (code farmer )