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
    You cannot run programs from the SD card, as it is mounted with the noexec flag. See e.g. this answer. – Izzy Feb 8 '17 at 16:05

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!

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.