提问人:iotop 提问时间:11/8/2023 更新时间:11/8/2023 访问量:48
Windows GCC 程序不输出 [重复]
Windows GCC program does not output [duplicate]
问:
我使用UCRT终端在Windows(MSYS2)上安装了GCC,命令如下:
pacman -S --needed base-devel mingw-w64-ucrt-x86_64-toolchain
我添加到路径,我可以在 Windows 中调用。C:\msys64\ucrt64\bin
g++
然后我在 Windows 终端上编译了一个简单的 c++ 程序,没有编译错误:
#include <iostream>
using namespace std;
int main()
{
cout << "hello world\n";
return 0;
}
PS C:\Users\tom\source\cpp> g++ .\main.cpp
PS C:\Users\tom\source\cpp> .\a.exe
PS C:\Users\tom\source\cpp>
2 秒后,程序结束,没有任何输出。
请注意,如果我在 UCRT 终端中编译并运行相同的程序,它将完美运行。
当我避免使用 c++ 语言功能时,即使我包含 c++ 库,也不会发生此问题。例如,以下程序不会导致此问题:
#include <iostream>
using namespace std;
int main()
{
printf("hello world\n");
return 0;
}
答: 暂无答案
评论