1

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

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

我需要root还是其他?

4

4 回答 4

0

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

g++ test.cpp

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

./a.out
于 2018-10-30T12:35:45.110 回答
0

在 termux 自己的目录中编译并运行它。只需启动 termux:

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

你可以运行它!

于 2019-10-01T17:51:46.327 回答
0

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

于 2020-08-28T07:02:20.233 回答
-1

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

  • 用于chmod 777 test.cpp授予所有用户读写和执行权限
  • 使用 g++ 和 gcc 来编译 C++ 文件使用sudo apt-get update后跟sudo apt-get install g++
  • 编译使用g++ test.cpp -o test 和使用./test来执行文件。这就是它在 Linux 系统中的工作方式。
于 2018-10-30T12:56:37.020 回答