Unresolved external symbol "public: virtual struct QMetaObject const * __thiscall Parent

unresolved external symbol lnk2001
unresolved external symbol c
unresolved external symbol c++ lnk2019
error lnk2019: unresolved external symbol referenced in function
c unresolved external symbol static
unresolved external symbol class
c++ library unresolved external symbol
unresolved external symbol glad

I inherited a class from QObject :

class Parent: public QObject
    QObject* cl;

    Parent(QObject *parent=0):QObject(parent) {
        cl = NULL;

    QObject* getCl() const {
        return cl;
    void setCl(QObject *obj) {
        cl = obj;

But when I write :

Parent ev;

I get the following error:

main.obj:-1: error: LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall Parent::metaObject(void)const " (?metaObject@Parent@@UBEPBUQMetaObject@@XZ)

main.obj:-1: error: LNK2001: unresolved external symbol "public: virtual void * __thiscall Parent::qt_metacast(char const *)" (?qt_metacast@Parent@@UAEPAXPBD@Z)

main.obj:-1: error: LNK2001: unresolved external symbol "public: virtual int __thiscall Parent::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@Parent@@UAEHW4Call@QMetaObject@@HPAPAX@Z)

You should delete the debug folder of your application and run it again to correct this problem.

How to solve the error LNK2019: unresolved external symbol , One option would be to include function.cpp in your UnitTest1 project, but that may not be the most ideal solution structure. The short answer to  An unresolved symbol is one that you've declared somewhere but never defined. Usually, it means you've #included some third party library's header file but not told the linker where to find the corresponding .obj files for the library. – deong Mar 29 '12 at 15:16. Pretty common mistake is that you define a function as a standalone and forget

If you're using Visual Studio, delete the line Q_OBJECT from the header file, save the file, put Q_OBJECT back into the header file, save the file again. This should generate the moc_* file and should build and link correctly.

Linker Tools Error LNK2019, unresolved external symbol 'symbol' referenced in function 'function'. The compiled code for function makes a reference or call to symbol, but  unresolved external symbol 'symbol' referenced in function 'function' The compiled code for function makes a reference or call to symbol , but the linker can't find the symbol definition in any of the libraries or object files to link.

I noticed some answers are based on Visual Studio.

This answer is based on Qt Creator.

Unlike the name suggest, Rebuild Project will not wipe out everything and build from scratch. If you recently added QObject (and/or Q_OBJECT) to your class, you'll have to run qmake again, e.g.

  1. Clean Project
  2. Run qmake
  3. Build Project

This is because, by default, qmake only runs when you do significant changes to your solution like adding new source files or modify the .pro file. If you make edits to an existing file, it doesn't know it needs to run qmake.

As a fall back, to brute force Qt to build everything from scratch, delete the Debug or Release folder.

[Solved] How to solve the issue of unresolved external symbol in , Try to replace. Hide Copy Code. #include"function1.hpp" with. Hide Copy Code. #include"function1.cpp". It was caused by a class destructor in a class defined in one of my other .cpp files. I had included libirc.lib and apparently _atexit is used to signal the code within class destructors.

So the issue was I needed the Qt MOC compiler to compile my .h file. This is required for any classes that extend QObject or one of its children. The fix involed (for me) right-clicking on the header file, choosing Properties, and setting the Item Type to "Qt MOC Input", then hitting "Compile" on the header, and then adding the resulting moc_myfilename.cpp file to my project.

LNK2019 unresolved external symbol - C++ Forum, Does anyone know what this means? Severity Code Description Project File Line Error LNK2019 unresolved external symbol "protected: virtual  @Niklas Vest: If everything is there, in the header, then the compiler/linker should be able to find everything without any problems. I.e. LNK2001 simply will not occur. Placing inappropriate things into header files usually elevates risk of LNK2005, which is on the other end of the spectrum: too many definitions. – AnT Apr 1 '16 at 16:52.

If your moc files are generated in the visual studio project try to include them into project if they are not included into project then rebuild.

MEX error LNK2019: unresolved external symbol, qpip.obj : error LNK2019: unresolved external symbol dcopy referenced in function mexFunction. qpip.mexw64 : fatal error LNK1120: 2 unresolved externals. unresolved external symbol "symbol" The compiled code makes a reference or call to symbol . The symbol isn't defined in any libraries or object files searched by the linker.

mexFuncion.obj : error LNK2019: unresolved external symbol , obj : error LNK2019: unresolved external symbol _mxGetPr referenced in function _mexFunction. Follow. 79 views (last 30 days). Create a new project and select Console Application as the Project Type, or add a project to the existing Project. To Create a new target for an existing project with Visual C++ 2.x, from the Project menu, choose Targets, and select New

error LNK2019: unresolved external symbol __imp_strdup · Issue , error LNK2019: unresolved external symbol __imp_strdup #1212. Closed. looooo opened this issue on Dec 10, 2017 · 2 comments. Closed  Undefined reference/unresolved external symbol errors in C++/C/Objective-c and ways to solve/avoid them.

Unresolved External Symbol, Hi,I want to use dgemm function from mkl lib in my (C++) program but i keep getting linking error could you please help me with this?

  • I'm having the same issue. Deleting the debug folder didn't help. Any more ideas?
  • @Vern Jensen, check for Q_OBJECT macro, then rebuild, then delete debug/release folder (to delete all moc files) and rebuild again. One of this should help.
  • removal of Q_OBJECT macro from the class, save and adding Q_OBJECT again worked for me when using the QT5 Plugin for VS 2012
  • This fixed my issue too. But why and how? Anyone please explain. Thanks!
  • I was having the same issue for a class project. I found that flat out removing Q_OBJECT macro fixed my problem. No idea why. But if I put it back I receive the same 3 unresolved errors. I fixed that problem by including the new classes inside of the .pro file for QT and the cmakelists.txt file I'm using. Once I included the header and the cpp files the code worked with QObject.
  • None of the other solutions worked for me but this did! Thanks! ;)
  • If you're using CMake, ensure that you have set(CMAKE_AUTOMOC ON)
  • this answer should also be noted as a valid answer !
  • Woks for me (VS2017), thanks. Compiles with "Q_OBJECT" commented out, does not compile if restored. Does not inspire confidence in Qt. I thought the "Q_OBJECT" macro was necessary?
  • Brilliant! Worked for me. "Run qmake" is the key step. Q_OBJECT is necessary if you're going to use slots.
  • Where exactly do you find this "properties"? In Qt Creator I do not see anything like this on right click.
  • This is in XCode, right-clicking on the file listed in the "Navigator" view (the list of files your project uses).