c++ mingw STL installation
c++ mingw STL installation
我最近在我的Windows 32机器上安装了MinGW和MSYS,它似乎运行得很好。
在C++编译器上,我包含了一个向量容器,并且没有任何错误。但当我尝试使用它时,我会遇到编译时错误。
所以,代码
#include <vector> // include vector.h
#include <stdio.h> // include stdio.h
using namespace std;
main() {
// vector<int> A;
printf("nHeya ..");
}
运行良好。然而,当我取消注释第8行——矢量声明行时,我在编译时间中得到了以下错误(缩短):
undefined reference to 'operator delete(void*)'
undefined reference to '__gxx_personality_v0'
您可能使用gcc
而不是g++
进行编译。实际的编译器是相同的,但g++
告诉链接器使用默认的C++库,而gcc
只是告诉它查看C库。一旦使用了标准库中特定于C++的部分,gcc
就会失败。
顺便说一句,C++不支持旧C中的default int
规则,所以您应该从main
中指定返回类型。
我不知道您是如何编译代码的。您的主方法无效,签名不正确,并且没有返回任何内容。
应该是这样的:
#include <vector> // include vector.h
#include <stdio.h> // include stdio.h
using namespace std;
int main(int, char**) {
// vector<int> A;
printf("nHeya ..");
return 0;
}
此外,您需要使用g++而不是gcc来编译它。
相关文章:
- 在C++STL中是否有Polyval(Matlab函数)等价物?
- 为什么这个运算符<重载函数对 STL 算法不可见?
- 在C应用程序中运行C++(带有STL)函数
- 使用2个键的cpp-stl::优先级队列排序不正确
- 在STL容器中使用模板类
- 用C++中的CPerson(类)类型的对象初始化STL矢量
- 将stl字符串缩小到小于15个字符的容量
- 在为LINUX创建共享库时,如何避免STL的私有/弱副本
- 检查函数返回类型是否与STL容器类型值相同
- STL算法函数在多个一维容器上的使用
- 在STL - C++中按成绩对学生列表进行排序?
- 为什么 STL 容器适配器堆栈中的 top 返回常量引用?
- λ可以适应STL吗?
- 为什么使用 NDK 不能存在不同的 stl 实现?
- 如果我真的真的想从 STL 容器继承,并且我继承构造函数并删除新运算符,会发生什么?
- 使用 char 分隔符解析C++中的字符串,但将可重复的字符保留为每个解析的子字符串 (C++ STL) 中的分隔符
- 在C++中迭代 STL 集时出现奇怪的问题<CStudent>
- 如何在 C++17 STL 并行算法中处理调度?
- 在学习数据结构之前对STL有一个了解是好的吗?
- c++ mingw STL installation