Termux 权限被拒绝

Termux permission denied

我想在 Termux(c++) 中执行一个简单的代码,但每次我都遇到错误:

bash: ./test.cpp: Permission denied
Storage permission is on and gcc is installed. 

我需要 root 还是其他?

正如 molbdnilo 所说,您应该先编译源文件:

g++ test.cpp

然后执行生成的二进制文件(默认名称是a.out)

./a.out

我从未使用过 termux,但想建议您遵循以下编译要点

  • 使用chmod 777 test.cpp给所有用户授予读写和执行权限
  • 使用 g++ 和 gcc 编译 C++ 文件 使用 sudo apt-get update 后接 sudo apt-get install g++
  • 使用g++ test.cpp -o test编译 并使用 ./test 来执行文件。 这就是它在 Linux 系统中的工作方式。

在 termux 自己的目录中编译并运行它。 刚开始 termux:

cd storage/ 
nano test.cpp
g++ test.cpp "./a.out" 

可以运行啦!

C++做不到,必须先编译。 如果是Python,你可以在第一行添加#!/usr/bin/env python,然后在shell 运行 chmod 744 xxx.py,然后是运行 ./xxx.py.xxx.py是运行宁.