3

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?

valiano
  • 16,433
  • 7
  • 64
  • 79
tech_learner
  • 725
  • 11
  • 21
  • 31

1 Answers1

2

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.

jonsca
  • 10,218
  • 26
  • 54
  • 62
  • Hi Jonsca, Thanks for the reply. But as I said before, I am bad in understanding lib funda. By header files for the library do you mean the header files that I have created for my program or any pre-defined header files for the standard libraries which I am using. – tech_learner Mar 21 '11 at 02:43
  • 1
    The library's headers go in the space in the Properties dialog. You could conceivably keep your own headers in a folder c:\headers or something, and put that directory in the slot also, but it's not necessary, the compiler will find yours in the folder of the project. Basically, you're just telling the compiler that here's a directory in which you can search for my headers, here's a directory in which you can search for the lib file, and here's some possible lib files in which to find these functions. Don't despair, once you've done this a couple of times, it's old hat. – jonsca Mar 21 '11 at 03:58
  • My issue was the 3rd step. I am unit testing my application and needed to remember to add the `.obj`s to the Linker/Input. – CaptainBli Oct 15 '13 at 16:16