问题描述
我在c ++中使用std::ifstream
时遇到问题。我使用的是Visual Studio2019。每次我想初始化std::ifstream
对象时,都会出现以下错误:
文件: Shader.obj
函数“ void * __cdecl std :: __ Allocate_manually_vector_aligned(unsigned int)”(?? $ _ Allocate_manually_vector_aligned @ U_Default_allocate_traits @ std @@@ std @@ YAPAXI>中引用的LNK2019不可解析的外部符号__imp___invalid_parameter
LNK2019无法解析的外部符号__imp___CrtDbgReport在函数“ void * __cdecl std :: __ Allocate_manually_vector_aligned(unsigned int)”中引用(?? $ _ Allocate_manually_vector_aligned @ U_Default_allocate_traits @ std @@@ std @@ YAPA
文件: msvcprtd.lib(locale0_implib.obj)
在函数“ public:static void __cdecl std :: _ Fac_node :: operator delete(void *)”中引用的LNK2019不可解析的外部符号__imp ___ free_dbg(?? 3_Fac_node @ std @@ SAXPAX @ Z)
在函数“ public:static void * __cdecl std :: _ Fac_node :: operator new(unsigned int)”中引用的LNK2019不可解析的外部符号__imp___malloc_dbg”(?? 2_Fac_node @ std @@ SAPAXI @ Z)
Shader.h
#pragma once
#include <iostream>
#include <fstream>
#include <string>
#include <GLFW/glfw3.h>
#include <glm/vec3.hpp>
#include <glm/vec4.hpp>
#include <glm/mat4x4.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
class Shader
{
private:
/* some code */
public:
/* some code */
void setSourceFile(const std::string& filename);
}
Shader.cpp
#include "Shader.h"
/* some code */
void Shader::setSourceFile(const std::string& filename)
{
std::ifstream* shaderFile = new std::ifstream();
}
即使我仅运行std::ifstream shaderFile();
,甚至在将参数传递给构造函数之后,这些错误仍然存在。当我对此发表评论时,程序会正确构建。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)