c++ 尝试使用g++在VSCode中编译代码并获得错误[关闭]

5cg8jx4n  于 2024-01-09  发布在  Vscode
关注(0)|答案(1)|浏览(267)

**已关闭。**此问题为not reproducible or was caused by typos。目前不接受回答。

这个问题是由错字或无法再重现的问题引起的。虽然类似的问题在这里可能是on-topic,但这个问题的解决方式不太可能帮助未来的读者。
7天前关闭
Improve this question
下面是一个例子:

  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. cout << "Hello world!" << endl;
  6. return 0;
  7. }

字符串
以下是我在终端中得到的:

  1. * Executing task: C/C++: g++.exe build active file
  2. Starting build...
  3. C:\mingw64\bin\g++.exe -fdiagnostics-color=always -g C:\Users\Mohamed's PC\Desktop\CodeBlocks\file\main.cpp -o C:\Users\Mohamed's PC\Desktop\CodeBlocks\file\main.exe
  4. cc1plus.exe: fatal error: PC\Desktop\CodeBlocks\file\main.cpp: No such file or directory
  5. compilation terminated.
  6. Build finished with error(s).
  7. * The terminal process failed to launch (exit code: -1).
  8. * Terminal will be reused by tasks, press any key to close it.


error in a screenshot
尝试在youtube上用各种不同的方法安装mingw64,即使编译器工作,它也只是运行由coderunner扩展创建的exe文件,不能自己创建新的exe文件。

6bc51xsx

6bc51xsx1#

把路径用“”包起来,因为路径中有空格。所以我们用“”或“”来转义任何特殊字符,这样就可以了。

  1. C:\mingw64\bin\g++.exe -fdiagnostics-color=always -g "C:\Users\Mohamed's PC\Desktop\CodeBlocks\file\main.cpp" -o "C:\Users\Mohamed's PC\Desktop\CodeBlocks\file\main.exe"

字符串

相关问题