Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Unresolved external Error QtMetaObject
Forum Updated to NodeBB v4.3 + New Features

Unresolved external Error QtMetaObject

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 593 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JohnSRV
    wrote on last edited by JohnSRV
    #1

    Hello Everyone,

    I'm trying to implement a simple server client application in QT. I'm using Visual Studio 2017.
    Here's the Header File to my client class.

    #pragma once
    #ifndef  Client_H
    #define	Client_H
    
    #include <QTcpSocket>
    
    
    class Client : public QObject 
    {	Q_OBJECT
    
    public: 
    	 explicit Client (QObject *parent = 0);
    	
    	 void Connect(); 
    
    signals: 
    
    public slots: 
    
    private:
    	QTcpSocket *socket; 
    };
    #endif
    

    and here's the code to Client.cpp

    #include "Client.h"
    
    Client::Client(QObject *parent) :
    	QObject(parent)
    {
    }
    
    void Client::Connect()
    {
    	socket = new QTcpSocket(this); 
    	socket->connectToHost("192.168.10.10", 8016); 
    	if (socket->waitForConnected(3000))
    	{
    		printf("COnnected");
    	}
    	else
    	{
    		printf("Not Connected");
    	}
    }
    

    as you can see it's pretty simple. In my Main.cpp i create an instance of the client class and then call the function Connect():

    Client Test;
    Test.Connect(); 
    

    When building my project i get the following errors

    1>Client.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __cdecl Client::metaObject(void)const " (?metaObject@Client@@UEBAPEBUQMetaObject@@XZ)
    1>Client.obj : error LNK2001: unresolved external symbol "public: virtual void * __cdecl Client::qt_metacast(char const *)" (?qt_metacast@Client@@UEAAPEAXPEBD@Z)
    1>Client.obj : error LNK2001: unresolved external symbol "public: virtual int __cdecl Client::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@Client@@UEAAHW4Call@QMetaObject@@HPEAPEAX@Z)
    

    I know that this Error means that the functions are declared but the definition is missing. I just don't know where to find these definitions and which file i have to link to get rid of these errors.

    Thank you

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      Try to clean build folder (delete it) and rebuild all.

      can a default gui project run so we know VS is setup to link to Qt etc ?

      I would imagine we got more errors if no QtDLL was found.

      1 Reply Last reply
      0
      • J Offline
        J Offline
        JohnSRV
        wrote on last edited by
        #3

        @mrjj Hey thanks.

        Qt is already linked to VS and i already can run some other prjects
        the problem seems to only arise with this class

        1 Reply Last reply
        0
        • B Offline
          B Offline
          Bonnie
          wrote on last edited by
          #4

          The definitions should be in the auto generated moc_Client.cpp which is also linked automatically.
          So I agree with clean and rebuild if other projects's mocing has no problem.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved