使用标准输入流会导致编译失败

using the standard input stream leads to compilation failure

本文关键字:编译 失败 标准输入流      更新时间:2023-10-16

运行简单的c++程序(例如HelloWorld)没有问题,但当我在代码中使用cin时,我看到以下错误

在中找不到过程入口点__gxx_personality_v0动态链接库C:\Users\username\Desktop\helloworld.exe

我使用MinGW编译器,在windows 10 上的精彩文本


代码:

#include <iostream>
using namespace std;
int main()
{
    int x = 1;
    cin >> x;
    cout << x << endl;
    return 0;
}

来自gcc邮件列表中的此存档https://gcc.gnu.org/ml/gcc-help/2002-07/msg00186.html,

__gxx_personality_v0是定义的G++异常处理模型的一部分GCC中新的C++ABI。符号由libstdc++提供库,通过g++添加到链接行。

因此,在这种情况下,我确信您使用了mingw-gcc来编译代码。切换到mingw-g++或在命令中添加-lstdc++将完成任务。