How to create and run c++ app in termux Android - Europe Geeks
C++ programming language it becomes more important for university students,
because many colleges teach there student c++ language, so it is really good
for beginner.
installing termux
We should go to play store (or any apps store) then write "Termux" in the search lab.
After that install it in the smartphone (it is about 15Mb only), then wait for downloading some packages if you opening it for the first time.
upgrade update termux to run c++ perfectly
In every process of working with termux, we should update and upgrade the distribution this step not only used to create and run c++ app in termux but
also in many setup tutorial setups, so we are going to do that with command:
pkg update && pkg upgrade
Notice that we separate two command by "&&", because so if the first one run, then the other will execute in the terminal.
create and edit c++ app in termux
Create a folder for saving the file of c++ by the command:
mkdir cpp
Then we are going to move in it:
cd cpp
Then typing "nano" to create a new c++ file in termux.
Note: if there is an error with "nano", so it may because you it is not installed yet, so type:
pkg install nano
Type all codes of c++ you have correctly, then save it using Ctrl + O after that type file name , for example "file.cpp" and do not forget the extand .cpp or .cxx , then save it, and exit using Ctrl + x.
installing clang library
Them you have to install the main editor (clang), easily type the following commands:
pkg install clang
Maybe it's already installed in case you used another tool required this library.
compile c++ app
After all this, you can compile the c++ in file using c++ or gcc lib, just type the c++ with the file name (including the extand .cpp or .cxx), then enter, if everything goes well so the program without syntax errors, but if it does not go well c++ or gcc will display the information about errors, debug in by nano then you will be able to run c++ program on termux.
how to run c++ on termux (executable bash program)
Finally we got the program compiled, after that process there is a bash file of linux created by the c++ compiler name is "a.out" c plus plus file executable, you can execute it using the following command:
./a.out
Then it is going to run easily, printing "Europe Geeks" like what is showing in the picture.
If you face any errors leave a description of it in comments.