1
votes

I encounter a problem about LNK2019 when I compile my project with Visual Studio 2010. Can anyone help me? Thanks.

gspan.obj : error LNK2019: 無法解析的外部符號 "public: class std::vector,class std::allocator >,class std::allocator,class std::allocator > > > __thiscall gSpan::tokenize(class std::basic_string,class std::allocator >)" (?tokenize@gSpan@@QAE?AV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@3@@Z) 在函式 "private: void __thiscall gSpan::read(class std::basic_string,class std::allocator >)" (?read@gSpan@@AAEXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) 中被參考

C:\Users\cool\documents\visual studio 2010\Projects\OGSPAN\Debug\OGSPAN.exe : fatal error LNK1120: 1 個無法解析的外部符號

2

2 Answers

1
votes

Please check you source code, the method gSpan::tokenize is not implemented. It's called in gSpan::read. By the way, gSpan::is_min is not implemented too.

You can use dumpbin.exe to examine the generated gspan.obj. All other gSpan:: methods are defined in SECT??(where ?? is two hex digits I think) sections, While gSpan::tokenize and gSpan::is_min are UNDEF.

To recreate the error, use this code:

class a {
public:
    void func1(void);
    void func2(void);
};

void a::func1(void)
{
    func2();
}

int _tmain(int argc, _TCHAR* argv[])
{
    a b;
    b.func1();
    return 0;
}
1
votes

LNK2019 means that one of your object files is referring to a symbol (function or variable name) that isn't defined in any of them. Often it means that you declared and called a function, but forgot to actually implement the function.