Search code examples
c++cobject-files

Link Object File in Visual Studio LNK2019


right now I am trying to use a function of an object file in my visual studio project. The object file is native compiled and generated outside the visual studio project and now the final goal would be to call a function of it in my .cpp file. The object file is named test.obj in this case. If I try to include it I get the following linker errors

Fehler LNK2019 Verweis auf nicht aufgelöstes externes Symbol ""public: __cdecl std::_Lockit::_Lockit(int)" (??0_Lockit@std@@QEAA@H@Z)" in Funktion ""class std::ctype const & __cdecl std::use_facet >(class std::locale const &)" (??$use_facet@V?$ctype@D@std@@@std@@YAAEBV?$ctype@D@0@AEBVlocale@0@@Z)". FlexDll C:\Users\ldeppler\Desktop\FLEXDLLNEW\FlexDll\test.obj

I get about 40 of these errors

Fehler LNK2019 Verweis auf nicht aufgelöstes externes Symbol "_Getctype" in Funktion ""public: struct _Ctypevec __cdecl std::_Locinfo::_Getctype(void)const " (?_Getctype@_Locinfo@std@@QEBA?AU_Ctypevec@@XZ)". FlexDll C:\Users\ldeppler\Desktop\FLEXDLLNEW\FlexDll\test.obj

My object file is compiled by this command:

cl /EHsc /c /MT /I. test.cpp


Solution

  • Many things can cause LNK2019 error.

    But most probably either appropriate function declarations are not exist or not spelled correctly in your current project.

    You can have the appropriate function declarations by including the header file that is used to create object file or pasting the them at the beginning of your cpp files where the functions are used.