문제

I am compiling my Qt project using compiler MSVC2008, and I am getting linker errors like-

_class_name.obj_:error LNK2001: unresolved external symbol "public: static struct QMetaObject...."... referenced in a function "_function_name_"

_class_name.obj_:error LNK2019: unresolved external symbol "public: static struct QMetaObject..." ... referenced in a function "_function_name_"

I have few basic queries-

  1. what does it mean by errors LNK2001 and LNK2019?

  2. Why these error occurs?

  3. How to resolve these?

NOTE: I am using QtCreater so build system uses qmake and compiler used is MSVC2008.

도움이 되었습니까?

해결책

  1. In a nutshell, you used a function which is declared but not defined.

  2. It should be caused by your classes using Qt functionality (like signal-slots) but incorrectly.

  3. Here's possibilities I can think of:

    3-a. Double check you've written "Q_OBJECT" at the beginning of your class that use Qt functionality.

    3-b. You call "moc" property, i.e. check if your Qt Visual Studio plugin is installed and enabled.

다른 팁

You've included the wrong/too little files or forgot to add .lib files to the Linker in msvc.

Check under linker's Additional Dependencies property for: QtCore5.lib - for Qt5 Release QtCore5d.lib - for Qt5 Debug

QMetaObject is included in one of those, but they might not be the only dependencies in your project.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top