2

I have just installed termux in my Android 6 phone and have given storage permissions so I can read, write or compile from the terminal in the folder /sdcard/myC/ by using clang -o birthday birthday.c -lm. However, when I try to run the executable, I get -bash: ./birthday: Permission denied.

I have tried compiling and running in multiple places, i.e. /sdcard/data/com.termux, and have tried the command termux-setup-storage that ensures the permissions are granted to read/write. I have tried to chmod the program as well.

I should be doing something wrong because apparently, the app is really good.

1
  • 1
    You cannot run programs from the SD card, as it is mounted with the noexec flag. See e.g. this answer.
    – Izzy
    Feb 8, 2017 at 16:05

2 Answers 2

4

Finally I got it to work. Programs can only be run if they are located at the home directory of termux. That is, run pwd to know where the home directory is and put the source files there, then compile and run, enjoy!

1
  • 3
    It is not necessary to put source there, just the binary. Of course you can just copy the binary afterwards.
    – user186920
    Feb 9, 2017 at 1:30
1

Files store on /sdcard cannot have execution permission on android.

You can copy the binary generated to /data/data/com.termux/files/home/directory/of/your/choice.

Then make it executable by using chmod

Or, you can use this program to do that for you.

Usage:

binrun <your executable> <arguments...>

Ps: I made that program

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .