C++ 矢量回推错误
c++ vector push back error
每次
我尝试使用 Visual C++ 2008 调试它时都会收到错误
#include <iostream>
#include <vector>
#include <string>
#include <fstream>
using namespace std;
void load(const char* filename) {
vector <string*> vec;
ifstream in(filename);
char buffer[256];
while(!in.eof()) {
in.getline(buffer, 256);
vec.push_back(new std::string(buffer));
}
}
int main(int argc, char* args[]) {
cin.get();
return 0;
}
收到此错误
Compiling...
main.cpp
Linking...
main.obj : error LNK2019: unresolved external symbol __imp___CrtDbgReportW referenced in function "public: __thiscall std::_Vector_const_iterator,class std::allocator > *,class std::allocator,class std::allocator > *> >::_Vector_const_iterator,class std::allocator > *,class std::allocator,class std::allocator > *> >(class std::basic_string,class std::allocator > * *,class std::_Container_base_secure const *)" (??0?$_Vector_const_iterator@PAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@PAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@QAE@PAPAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@PBV_Container_base_secure@1@@Z)
E:blablaDebugtest2.exe : fatal error LNK1120: 1 unresolved externals
我做错了什么?
看起来好像您正在构建项目的调试版本,但您正在链接到 C 运行时 DLL 的非调试版本。 您可以在以下位置签到:
[Project] -> Properties -> C/C++ --> Code Generation --> Runtime Library
运行时库应列为:"多线程调试 DLL (/MDd)",用于调试版本。
您实际上应该发现该项目构建为"发布"很好,因为CrtDbgReportW
在发布版本中没有被std::vector
调用,因此不需要在链接时找到该符号。
相关文章:
- 警告处理为错误这里有什么问题
- "error: no matching function for call to"构造函数错误
- boost::进程间消息队列引发错误
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- 有关插入适配器的错误。[错误]请求从 'back_insert_iterator<vector<>>' 类型转换为非标量类型
- QT在错误的班级中寻找空位
- vector.resize()中的分配错误
- 代码在main()中运行,但在函数中出现错误
- 释放错误后堆使用
- (C++)分析树以计算返回错误值的简单算术表达式
- Project Euler问题4的错误解决方案
- 我的字符计数代码计算错误.为什么
- 从"int*"强制转换为"unsigned int"会丢失精度错误
- 尝试导入pybind-opencv模块时出现libgtk错误
- CMake项目Boost库错误:Boost/config/compiler/gcc.hpp:165:10:致命错误:cs
- 在某些循环内使用vector.push_back时出现分段错误
- MSVC多行宏编译器错误
- 静态数据成员的问题-修复链接错误会导致编译器错误
- 为什么在运行时没有向我们提供有关分段错误的更多信息?
- 错误:未在此范围内声明'reverse'