Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8413645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:57:28+00:00 2026-06-10T00:57:28+00:00

I have Qt libraries 4.8.1 for Windows (VS 2010 ultimate) with Qt Visual Studio

  • 0

I have Qt libraries 4.8.1 for Windows (VS 2010 ultimate) with Qt Visual Studio Add-in. This is my very simple app :

#include<qobject.h>
#include<qstring.h>
#include<memory>

class MyClass : public QObject{
Q_OBJECT

public:
MyClass( const QString &text, QObject *parent = 0 ) : m_text(text) {}

public slots:
void setText( const QString &text );

signals:
void textChanged( const QString& );

private:
QString m_text;
};

void MyClass::setText( const QString &text ){
if( m_text == text ) return;
m_text = text;
emit textChanged( m_text );
}

int main(int argc, char *argv[]){
    std::shared_ptr<MyClass> a(new MyClass("foo"));
    std::shared_ptr<MyClass> b(new MyClass("bar"));

QObject::connect( a.get(), SIGNAL(textChanged(const QString&)),
b.get(), SLOT(setText(const QString&)) );
a->setText("changed");
}

Errors I get related to unresolved externals : Error 6 error LNK2001:
unresolved external symbol “public: virtual int __thiscall
MyClass::qt_metacall(enum QMetaObject::Call,int,void * *)”
(?qt_metacall@MyClass@@UAEHW4Call@QMetaObject@@HPAPAX@Z)

Error 4 error LNK2001: unresolved external symbol “public: virtual
struct QMetaObject const * __thiscall MyClass::metaObject(void)const ”
(?metaObject@MyClass@@UBEPBUQMetaObject@@XZ)

Error 5 error LNK2001: unresolved external symbol “public: virtual
void * __thiscall MyClass::qt_metacast(char const *)”
(?qt_metacast@MyClass@@UAEPAXPBD@Z)

Error 3 error LNK2019: unresolved external symbol “protected: void
__thiscall MyClass::textChanged(class QString const &)” (?textChanged@MyClass@@IAEXABVQString@@@Z) referenced in function
“public: void __thiscall MyClass::setText(class QString const &)”
(?setText@MyClass@@QAEXABVQString@@@Z)

and two warnings :

Warning 1 warning MSB8017: A circular dependency has been detected
while executing custom build commands for item
“GeneratedFiles\Debug\main.moc”. This may cause incremental build to
work incorrectly.

Warning 2 warning : No resources in
‘C:\Users\Anonymous\documents\visual studio
2010\Projects\qtWorld\qtWorld\qtworld.qrc’.

I didn’t use any qmake / nmake . They ain’t required when you get latest Qt Visual Studio Add-in 1.1.11 (even Intellisense recognizes the keywords slots: signals:), right?

Now my questions :

  1. I heard many errors are resolved by just rebuilding the whole solution , why is that ?
  2. Please explain why I get these errors in deep and their possible solutions.

p.s please be good at explanation, don’t be rep whorer

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T00:57:29+00:00Added an answer on June 10, 2026 at 12:57 am

    If you have QObject class defined in cpp file then you should also include moc for that file.
    For example your MyClass is defined in main.cpp then you should add

    #include "main.moc"
    

    to end of your main.cpp file.

    Thanks to @Tomma for providing the unexplained answer 😛

    Explanation why above code didn’t work :

    However, the moc is typically applied to header files only. Since your class definition is part of the main program file, the IDE does not recognize it.

    Thanks to @koahnig for providing nice explanation

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have issues to build a project using external libraries with Visual Studio 2010
I have several Windows Service projects in one solution in Visual Studio 2010, they
I am using Microsoft Visual Studio 2010 and the OpenCV 2.3.0 libraries to write
My Visual Studio 2010 (with Service Pack 1) install is corrupted. This is on
Environment: Windows XP. Visual Studios 2010. Language - C++. I have run into the
I have problem during installing visual c++ runtime libraries for windows 7. I prepare
I have written a program on Visual C# 2010 Express on Windows 7, 64
I have a .NET 4.0 web site which was coded in Visual Studio 2010.
Under Windows, I have used a program called Dependency Walker to examine the libraries
Friends I have been using Microsoft Visual C++ 2010 Express edition and also downloaded

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.