Search code examples
c++windowslnk2019visual-c++-2012

error LNK2019:unresolved external symbol ::FindWindow() function


I have function findId(const QString& name) that throws me an error during coompilation:

error LNK2019: unresolved external symbol __imp__FindWindowW@8 referenced in function "private: unsigned int__thiscall MainClass::findId(class QString const &)"(findId@MainClass@@AAEIABVQString@@@Z)

mainclass.cpp:

WId MainClass::findId(const QString& name)
{
  return (WId) ::FindWindow(NULL, (TCHAR*)name.utf16());
}

I don't know where the problem is because I have used this code before in my other project and there it worked. Maybe I missed something.


Solution

  • In the Solution Explorer, you have several tabs. One of the tabs is called "Property Manager", open this tab. In this tab you will find your project and its configurations. What it actually contains are Property Sheets, one of them being "Core Windows Libraries". If you right-click this one, and go to Linker->Input, you will find the Windows libraries user32.lib, etc. These properties are inherited by your project throught %(AdditionalDependencies).

    One of these things is not properly set up in your current project.