Lnk Error 2001

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mickey22
    New Member
    • Feb 2007
    • 105

    Lnk Error 2001

    I am using a function template in my project which is member of a class and I have included the header file of this class.But I am getting a linking error

    LNK 2001: error LNK2001: unresolved external symbol "public: float __thiscall test::fillvalue <float>(class std::basic_stri ng<char,struct std::char_trait s<char>,class std::allocator< char> >,class std::vector<cla ss h *,class std::allocator< class h *> > *,struct Filter::t * const,class std::basic_stri ng<char,struct std::char_trait s<char>,class std::allocator< char> >)" (??$fillvalue@M @test@@QAEMV?$b asic_string@DU? $char_traits@D@ std@@V?$allocat or@D@2@@std@@PA V?$vector@PAVKV @@V?$allocator@ PAVKV@@@std@@@2 @QAUtparam@Filt er@@0@Z)


    I have checked the parameters where the function template is called.I am not ablt to resovle it.Where can I check this error?Do I have to include something?

    Thanks in advance
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Firstly, you do not call templates.

    Templates are patterns used by the compiler to create functions. That means the function template must be in the same file as the the function call. In this case a copy of your test::fillvalue () function template will be made substituting float for the type. It is this function that the linker is looking for.

    That means, you cannot have your function template in another file and use it with function prototypes.

    The LNK2001 error from the linker says the test::fillvalue <float> function does not exist.

    If your template is in your included header file, be sure the function call matches the argument list in the template.

    Comment

    • mickey22
      New Member
      • Feb 2007
      • 105

      #3
      Thanks a lot for yourhelp.I have included the template definition also in the header file itself rather than in the .cpp file, then it worked.

      Thank you once again.

      Comment

      Working...