在 Windows 上的 ubuntu 中执行.sh文件
Execute .sh file in ubuntu on windows
我创建了一个文件,1.sh,作为
C++ -C 文件1.cpp
C++ 文件1.o -o 文件1
我试图在Windows上的bash Ubuntu上执行它。它告诉我
:没有这样的文件或目录
C++:致命错误:无输入文件
编译终止。
但是,如果我执行
C++ -C 文件1.cpp
C++ 文件1.o -o 文件1
直接,文件(File1.cpp(可以正常遵守。
我的问题是,文件不起作用的原因是什么.sh以及如何解决它?
实际上,我想将其写为评论,但没有可用的格式。(当这个答案过时时,我会删除它。
我刚刚尝试了这个(在cygwin的bash上使用g ++(:
$ g++ -c nothing.cc
g++: error: nothing.cc: No such file or directory
g++: fatal error: no input files
compilation terminated.
$
当然,我当前的工作目录中没有文件nothing.cc
在哪里......
所以,我的猜测(从 shell 脚本启动时C++在错误的工作目录中运行(可能是合理的......
正如我已经建议的那样:插入一个
echo "$PWD"
在 shell 脚本的开头可以肯定。
更新:
出于好奇,我也尝试了这个(cygwin,再次bash(:
$ c++ -c nothing.cc
c++: error: nothing.cc: No such file or directory
c++: fatal error: no input files
compilation terminated.
$
现在,它看起来与OP非常相似。
唯一让我感到困惑的事实:OP 的错误消息看起来像编译器是否没有得到任何输入:
$ c++
c++: fatal error: no input files
compilation terminated.
$
但我相信事实并非如此,因为在 OP 中它以
: No such file or directory
.
因此,看起来缺少一些文本...
相关文章:
- 在执行其他功能的同时播放动画(LED矩阵和Arduino/ESP8266)
- C++,系统无法执行指定的程序
- 使用C++中的模板和运算符重载执行矩阵运算
- 创建一个函数以在输入为负数或零时输出字符串.第一次执行用户定义的函数
- 执行函数时导致崩溃的变量
- 无论条件是否为true,if总是在c++中执行
- 当函数模板参数是具有默认参数的类模板时,函数模板参数的推导如何执行
- 在C++中对T*类型执行std::move的意外行为
- 使用QProcess执行命令,并将结果存储在QStringList中
- 如果我std::dynamic_pointer_cast并且底层dynamic_cast的结果为null,那么返回的sh
- 如何在没有信号的情况下从C++执行QML插槽
- 如何确认我的constexpr表达式实际上已经在编译时执行
- C++17中的并行执行策略
- QML按钮点击功能执行顺序
- 程序在执行程序的其余部分之前退出
- 为什么catch中的代码没有被执行
- C 可执行文件,SH 1:找不到
- 在 Windows 上的 ubuntu 中执行.sh文件
- 代码块编译"wrong" cpp.sh 正确执行
- 尝试执行文件时出现"sh: ./<file> not found"错误