Skip to content

Instantly share code, notes, and snippets.

@VirajKanse
Last active December 28, 2023 11:44
Show Gist options
  • Save VirajKanse/1c0db872cd7685632c02f8826397f190 to your computer and use it in GitHub Desktop.
Save VirajKanse/1c0db872cd7685632c02f8826397f190 to your computer and use it in GitHub Desktop.
GCC / Clang C/C++ Compiler On Android Using Termux (Linux Environment)
Install Termux App.
type "apt update"
Then We have to install a text editor to write our code so type "apt install vim" for vim text editor
or u can also use nano text editor for nano type "apt install nano"
Now Clang Installation type "apt install clang" and wait for download completes.
now to create a file simply type vim filename.c or .cpp or nano filename.c or cpp
then u will able to write ur code .
write.....to save ur code simply press esc then type ":wq"
now code is ready to compile
type "clang filename.c -o filename"
If ur code is right then it will be compiled.
Else it will show error.fix it.
To run ur program simply type "./filename".
Tada...Done.
1. apt update
2. apt install vim or nano
3. apt install clang
4. vim/nano filename.
5. clang filename.c -o filename
6. ./filename
@Saikatsaha1996
Copy link

Not working

What are the errors during installation or use?

See gcc not working
Screenshot_2021-06-29-22-57-43-835_com termux

@Saikatsaha1996
Copy link

Not working

What are the errors during installation or use?

No solution available ?

@pdaxrom
Copy link

pdaxrom commented Jun 30, 2021

Hi, letme check on the weekend, sorry

@Saikatsaha1996
Copy link

Hi, letme check on the weekend, sorry

Ok thank you
.. I am waiting
🙂

@Saikatsaha1996
Copy link

Not working

What are the errors during installation or use?

Screenshot_2021-07-01-12-29-36-183_com termux

@Saikatsaha1996
Copy link

Hi, letme check on the weekend, sorry

See please

When you free please try to slove I will give you report

Screenshot_2021-07-01-20-08-54-692_com termux

@Gustavo10Destroyer
Copy link

Gustavo10Destroyer commented Aug 27, 2021

Binary files can't run on Internal Storage, only on termux home folder

You need move the output to ~/ and use chmod +x filename

@AbdullahBinJahed
Copy link

Now GCC is available through its-pointless repo
pkg i gcc-11

@anik889
Copy link

anik889 commented Nov 26, 2021

Screenshot_2021-11-26-15-25-25-64
What is the problem here????
For a few days it started to show this kind of message while compiling the code

@MohdSaadJames
Copy link

@anik889 run pkg upgrade

@AhaomaMichael
Copy link

Screenshot_20220625-113421

@MohdSaadJames
Copy link

@AhaomaMichael type
apt update && apt upgrade
apt install clang
clang++ UserAge.cpp -o UserAge
./UserAge

@Tonylinks
Copy link

@AhaomaMichael type apt update && apt upgrade apt install clang clang++ UserAge.cpp -o UserAge ./UserAge

apt update && apt upgrade - Had couple of errors.
apt install clang - This returned an error "Unable to locate clang"

Any help would be highly appreciated. Thanks.

@Saikatsaha1996
Copy link

@AhaomaMichael type apt update && apt upgrade apt install clang clang++ UserAge.cpp -o UserAge ./UserAge

apt update && apt upgrade - Had couple of errors. apt install clang - This returned an error "Unable to locate clang"

Any help would be highly appreciated. Thanks.

pkg up && pkg upg
pkg i build-essential

@Tonylinks
Copy link

@AhaomaMichael type apt update && apt upgrade apt install clang clang++ UserAge.cpp -o UserAge ./UserAge

apt update && apt upgrade - Had couple of errors. apt install clang - This returned an error "Unable to locate clang"
Any help would be highly appreciated. Thanks.

pkg up && pkg upg
pkg i build-essential

Thanks so much. The fault was actually from me. I was using the playstore version.
Am still very new in the tech space :)
Thanks for the support.

@69r70e6
Copy link

69r70e6 commented Feb 21, 2023

It's not considering iostream header file and conio file

@ArnolDADI
Copy link

Working fine for everything else but not working for this short prime number code.

//GNU nano 7.2 004prime.c
#include<stdio.h>
int main(){
int a,b;
printf("enter the number to check prime : ");
scanf("%d\n",&a);
for(b=2;b<=a-1;b++){
if(a%b==0){
printf("%d is not a prime",a);
break;}}
if (b==a){
printf("%d is a prime\n",a);}
return 0;}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment