Linker error LNK2019 in C++ [duplicate]

こ雲淡風輕ζ 提交于 2019-12-07 15:22:16

问题


I am trying to build a C++ program and keep on getting LNK2019 link errors whenever I try defining a new function and building it. I resolved few of them till now, but spend a lot of time to understand the error in detail. Errors I am getting now are as per below:

Error 22 error LNK2019: unresolved external symbol "public: __thiscall xmlElements::operator class std::basic_string,class std::allocator >(void)" (??BxmlElements@@QAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) referenced in function "public: class xmlTags & __thiscall xmlTags::addSib(class xmlElements)" (?addSib@xmlTags@@QAEAAV1@VxmlElements@@@Z)

Error 25 error LNK2019: unresolved external symbol "public: __thiscall xmlElements::operator class std::basic_string,class std::allocator >(void)" (??BxmlElements@@QAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) referenced in function "public: class xmlTags & __thiscall xmlTags::addSib(class xmlElements)" (?addSib@xmlTags@@QAEAAV1@VxmlElements@@@Z)

Error 23 error LNK2019: unresolved external symbol "public: __thiscall xmlTags::xmlTags(void)" (??0xmlTags@@QAE@XZ) referenced in function "public: static void __cdecl xmlTags::makeDoc(void)" (?makeDoc@xmlTags@@SAXXZ)

Error 26 error LNK2019: unresolved external symbol "public: __thiscall xmlTags::xmlTags(void)" (??0xmlTags@@QAE@XZ) referenced in function "public: static void __cdecl xmlTags::makeDoc(void)" (?makeDoc@xmlTags@@SAXXZ)

Going through various forums I understood that I need to add some library name and its path, but I am bad at library thing. From where can I get its name and the path?


回答1:


To use a library: go under Project/<projectname>Properties/Configuration Properties/CC++/Additional Include Directories and enter in the directory where the header files for the library are.

Then also under Configuration Properties/Linker/General/Additional Library Directories enter in the location of the lib directory.

Then under Configuration Properties/Linker/Input/Additional dependencies put the name(s) of the lib files in the lib directory.



来源:https://stackoverflow.com/questions/5373152/linker-error-lnk2019-in-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!