Qwidget class-based dynamic library appears staticmetaobject ' of DllImport ' D class solution when 4.8.1 implicit invocation

Source: Internet
Author: User
specific tips are as follows:

APP\DEBUG\MOC_SCOPEWIDGET.CPP:56: Error: Definition of static data member ' Scopewidget::staticmetaobjectextradata ' of DllImport ' d class

There are also some caveats:

APP\DEBUG\MOC_SCOPEWIDGET.CPP:56: Warning: ' Scopewidget::staticmetaobjectextradata ' redeclared without dllimport Attribute after being referenced with DLL linkage

Not only do staticmetaobjectextradata have such warning messages, but there are also many other static functions.
thinking:

It is supposed that debug this place does not need to moc_scopewidget.cpp file, but in the project to add the corresponding Scopewidget.h header file, automatically generated this file, and caused errors.


process: originally to Qtcreator not too understand, at this time is not escape, a lot of Google, finally found a good post:

http://www.qtforum.org/article/26708/shared-library-compilation-error.html?s= 648c17887f3ae72775fc9386fc3c403e37ca7334#post92829

The general meaning is that there is no problem in SDK4.7.4, but this problem exists in 4.8.1.

The solution is simple and gives the force:

HEADERS + = mainwindow.h Libs/myclass/myclass.htryheaders + = Mainwindow.hheaders is processed by MOC, but don't need It this time. Http://doc.trolltech.com/4.4/qmake-varia...ce.html#headers#include "Libs/myclass/myclass.h"//only in unit where it is Used.

Follow the instructions to remove the ScopeWidget.h from the project and recompile the project tree. Conclusion:

Pro files in chunks

HEADERS + = mainwindow.h \

.. /scopewidget/scopewidget.h
Change to the following (delete the second line):

HEADERS + = Mainwindow.h
So 4.8.1 will not be in the main program Debug folder automatically generated moc_scopewidget.cpp files, there is no such as the error.

feeling: 1, found the problem clue, but did not really think to depth, too much reliance on the search.

2, mainly on the Qtcreator dynamic library is not familiar with the cause.

3, perception ah, perception, I am not many.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.