我想在 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 自己的目录中编译并运行它。只需启动 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 正在运行。
我从未使用过 termux,但想建议您遵循以下几点进行编译
chmod 777 test.cpp
授予所有用户读写和执行权限sudo apt-get update
后跟sudo apt-get install g++
g++ test.cpp -o test
和使用./test
来执行文件。这就是它在 Linux 系统中的工作方式。