Thursday, August 16, 2018

c++ - error LNK2001: unresolved external symbol, due to ifstream object


error LNK2001: unresolved external symbol "__declspec(dllimport) public: static class std::locale::id std::codecvt::id" (__imp_?id@?$codecvt@DDH@std@@2V0locale@2@A)



1>CAssertLog.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static unsigned int __cdecl std::codecvt::_Getcat(class std::locale::facet const * *,class std::locale const *)" (__imp_?_Getcat@?$codecvt@DDH@std@@SAIPAPBVfacet@locale@2@PBV42@@Z)



1>CAssertLog.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: int
__thiscall std::codecvt::unshift(int &,char *,char *,char * &)const " (__imp_?unshift@?$codecvt@DDH@std@@QBEHAAHPAD1AAPAD@Z)



1>CAssertLog.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: int __thiscall std::codecvt::out(int &,char const *,char const *,char const * &,char *,char *,char * &)const " (__imp_?out@?$codecvt@DDH@std@@QBEHAAHPBD1AAPBDPAD3AAPAD@Z)




1>CAssertLog.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: int __thiscall std::codecvt::in(int &,char const *,char const *,char const * &,char *,char *,char * &)const " (__imp_?in@?$codecvt@DDH@std@@QBEHAAHPBD1AAPBDPAD3AAPAD@Z)



1>C:\perforce\sw\apps\gpu\drivers\common\logassert\Release\logassert.dll : fatal error LNK1120: 5 unresolved externals




Issue Explanation:



Now I'm seeing above linking error when I add this source line "ifstream fin;" to source file. If I remove this source line then code successfully compiles. I already added supported header files and and namespace for ifstream object. Not sure, why I'm seeing this linking error. Searched similar error on SO and tried their suggested solutions but those solution didn't work for me. Any idea?




SAMPLE CODE



//In stdafx.h file below code is there 
#pragma once
#include
#include
using namespace std;

//In program.cpp

#include "stdafx.h"
class A
{
void B();
ifstream fin; //now if I make this member static then issue goes away. Can anybody explain?
}

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...