我想在Termux(c ++)中执行一个简单的代码,但每次遇到错误时:
bash: ./test.cpp: Permission denied
Storage permission is on and gcc is installed.
我需要root或其他东西吗?
答案 0 :(得分:0)
正如molbdnilo所说,您应该先编译源文件:
import grails.testing.web.controllers.ControllerUnitTest
import spock.lang.Specification
class MyTestControllerSpec extends Specification implements ControllerUnitTest<MyTestController> {
int index
def setup(){
index = 0
}
void "case 1: external object instantiation"() {
MyTestController controllerLocal = new MyTestController()
MyTestObject object = new MyTestObject()
controllerLocal.addObject(object)
object.edit()
MyTestObject afterEditInCollection1 = controllerLocal.getObjectFromCollection1(index)
MyTestObject afterEditInCollection2 = controllerLocal.getObjectFromCollection2(index)
expect:
"edited" == object.getValue()
"edited" == afterEditInCollection1.getValue()
"edited" == afterEditInCollection2.getValue()
}
void "case 2: internal object instantiation"() {
MyTestController controllerLocal = new MyTestController()
controllerLocal.addObject()
MyTestObject toBeEditedLocally = controllerLocal.getObjectFromCollection1(index)
toBeEditedLocally.edit()
MyTestObject afterEditInCollection1 = controllerLocal.getObjectFromCollection1(index)
MyTestObject afterEditInCollection2 = controllerLocal.getObjectFromCollection2(index)
expect:
"edited" == toBeEditedLocally.getValue()
"edited" == afterEditInCollection1.getValue()
"edited" == afterEditInCollection2.getValue()
}
def cleanup() {
}
}
然后执行生成的二进制文件(默认名称为a.out)
g++ test.cpp
答案 1 :(得分:0)
编译并在termux自己的目录中运行它。 只需启动termux:
cd storage/
nano test.cpp
g++ test.cpp "./a.out"
您可以运行它!
答案 2 :(得分:0)
C ++无法做到,必须先编译。
如果是Python,则可以将#!/usr/bin/env python
添加到第一行,然后在shell中运行chmod 744 xxx.py
,然后运行./xxx.py
。xxx.py正在运行。
答案 3 :(得分:-1)
我从没使用termux,但是想建议U以下几点进行编译
chmod 777 test.cpp
向所有用户授予读写权限并执行sudo apt-get update
,然后使用sudo apt-get install g++
g++ test.cpp -o test
进行编译
并使用./test
执行文件。
这就是它在Linux系统中的工作方式。