Search code examples
c++lnk2019

i am facing LNK2019 error uresolved external error


I am creating a text compression using huffman algorithm . In this I want to create a Huffman Tree , CreateHMNode accept two nodes and create a node with sum of frequency of others .

but it shows this error ,please help me to solve

LNK2019 unresolved external symbol "public: __cdecl HMnode::HMnode(void)" (??0HMnode@@QEAA@XZ) referenced in function "public: void __cdecl HMtree::build_tree(class HMnode *,class HMnode *)" (?build_tree@HMtree@@QEAAXPEAVHMnode@@0@Z)

void  build_tree(HMnode* temp3, HMnode* temp13)
{

    HMnode* head1;

    HMnode* newnode = new HMnode;
    newnode = createHMNode(temp3, temp13);
    head1 = newnode;
    HMnode* mytemp = calldeque();
    createHMNode(newnode, mytemp);

}

Solution

  • The HMnode::HMnode(void) mentioned in the error message is the HMnode default constructor.

    When you do new HMnode you default-construct a HMnode object, and it needs the default constructor.

    If, for some reason, you don't have a default constructor you will get an error about it. Normally you would get a compiler (not link) error, which means there's a declaration of the HMnode default constructor, but there's no definition (implementation).

    Either you don't link with all object files or libraries, or you forgot to define (implement) the default constructor in your code.