gpt4 book ai didi

c++ - Mingw 和 C++ vector

转载 作者:行者123 更新时间:2023-11-30 03:18:44 25 4
gpt4 key购买 nike

<分区>

我正在用 C++ 编写一个简单的小程序来测试 vector 。以下代码运行良好,并向 cmd 输出 hello。我遵循的步骤是:g++ filename.cpp 编译.\a.exe 运行

#include <iostream>
#include <vector>
using namespace std;

int main()
{

cout<<"hello";
return 0;
}

但是,当我声明一个 vector 时,hello 没有显示,程序似乎根本无法运行。

#include <iostream>
#include <vector>
using namespace std;

vector<int> a;

int main()
{

cout<<"hello";
return 0;
}

编译时我没有收到任何错误消息。但是当我在 cmd 之外运行时,我确实收到了一条关于没有入口点的消息。

The procedure entry point _ZNKSt9baisc_ioslcSt11char_traitslcEEcvbEv could not be located in the dynamic link library

我在 google 和 stack overflow 上进行了搜索,但找不到解决我的问题的方法。

对于任何稍后阅读本文的人,我在环境路径变量中安装并定义了一个名为 gtk 的东西,它似乎与 MinGW 发生了冲突。通过写作一切顺利:

g++ ex1.cpp -static-libgcc -static -static-libstdc++

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com