MinGW error: No such file or directory exists(MinGW 错误:不存在这样的文件或目录)
问题描述
我在 Windows XP SP3 上运行 MinGW.我用 C++ 编写了一个简单的程序并将其保存为 .cpp 文件.当我尝试在正确目录下的 MinGW 中编译它时,出现一条消息说错误:不存在这样的文件或目录"但我知道它在正确的目录中.
I'm running MinGW on windows XP SP3. I wrote a simple program in C++ and saved it as a .cpp file. When I tried to compile it in MinGW at the correct directory a message appeared saying " Error: No such file or directory exists" but I know its in the correct directory.
这是我在 MinGW 中输入的内容
This is what I typed into MinGW
cd C:MinGW test # Where I saved the .cpp file
g++ test.cpp -o test.exe
之后出现错误.
我也确实将环境设置路径更改为 C:MinGWin
Also I did change the Environment Settings path to C:MinGWin
推荐答案
要使其工作,您应该从程序所在的文件夹运行编译器,而不是 MinGW 所在的文件夹.首先,您需要设置 PATH 以包含 MinGW.您可以使用 set PATH = C:MinGWin;%PATH% 在命令行上执行此操作.
To get it to work, you should run the compiler from the folder where the program is, not where MinGW is. First, you need to set your PATH to include MinGW. You can do this with set PATH = C:MinGWin;%PATH% on the command line.
然后,cd到程序所在的位置,运行g++ test.cpp -o test.exe编译,test到运行.
Then, cd to where the program is located and run g++ test.cpp -o test.exe to compile, and test to run.
希望这有帮助!
这篇关于MinGW 错误:不存在这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:MinGW 错误:不存在这样的文件或目录
基础教程推荐
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- CString 到 char* 2021-01-01
- 初始化列表*参数*评估顺序 2021-01-01
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
