user1264836
user1264836

Reputation: 1

What does a unresolved external symbol error mean?

I'm programming an easy "bid on a house" application in C++. I compile and get this error msg:

1>Hus.obj : error LNK2019: unresolved external symbol "public: __thiscall 
Bud::Bud(void)" (??0Bud@@QAE@XZ) referenced in function "public: __thiscall 
Hus::Hus(int,class Person,class std::basic_string<char,struct 
std::char_traits<char>,class std::allocator<char> >)" 
(??0Hus@@QAE@HVPerson@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>F:\c++\prosjekter\Øving 4\Ov4Oppg1\Debug\Ov4Oppg1.exe : fatal error LNK1120: 1 
unresolved externals

Anyone have a clue?

Upvotes: 0

Views: 6784

Answers (2)

I've got the same error caused by a simple error: I forgot to implement one of my functions in the cpp file. When a object of other class called one object of this class that I've forgot to implement, this error appeared. I think that the error appears like a "linking error" because my function returns a type defined in other file of my project.

Noobie error... But it can be useful for someone...

Upvotes: 1

Luchian Grigore
Luchian Grigore

Reputation: 258548

You're getting the error because you haven't implemented

Bud::Bud()

which you call from Hus::Hus().

You most likely have something like:

class Bud
{
public:
   Bud();
}

and forgot to implement the constructor. You need to add

Bud::Bud() 
{
   //whatever
}

to an implementation file, compile and link to the obj file generated.

Upvotes: 2

Related Questions