MinGW 错误:不存在这样的文件或目录

2023-10-17C/C++开发问题
10

本文介绍了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 错误:不存在这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

无法访问 C++ std::set 中对象的非常量成员函数
Unable to access non-const member functions of objects in C++ std::set(无法访问 C++ std::set 中对象的非常量成员函数)...
2024-08-14 C/C++开发问题
17

从 lambda 构造 std::function 参数
Constructing std::function argument from lambda(从 lambda 构造 std::function 参数)...
2024-08-14 C/C++开发问题
25

STL BigInt 类实现
STL BigInt class implementation(STL BigInt 类实现)...
2024-08-14 C/C++开发问题
3

使用 std::atomic 和 std::condition_variable 同步不可靠
Sync is unreliable using std::atomic and std::condition_variable(使用 std::atomic 和 std::condition_variable 同步不可靠)...
2024-08-14 C/C++开发问题
17

在 STL 中将列表元素移动到末尾
Move list element to the end in STL(在 STL 中将列表元素移动到末尾)...
2024-08-14 C/C++开发问题
9

为什么禁止对存储在 STL 容器中的类重载 operator&()?
Why is overloading operatoramp;() prohibited for classes stored in STL containers?(为什么禁止对存储在 STL 容器中的类重载 operatoramp;()?)...
2024-08-14 C/C++开发问题
6