Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Linkage problems: LNK2001 QMetaObject
Qt 6.12 LTS is out! See what's new in the release blog

Linkage problems: LNK2001 QMetaObject

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 10.5k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    I'm coding a single class and inserting a single slot in that. In this class, I'm inheriting from QObject to use QObject::connect.
    When compiling QtCreator complains about linkage:

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

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

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

    I've read this link about moc: http://doc.qt.digia.com/4.7-snapshot/moc.html
    But it isn't applicable for make files only?
    Wht do I need to do to solve this constructor errors?

    My environment:
    Qt SDK4.8.1 in a windows environment.

    Below the declaration of my class:

    @
    #include <QList>
    #include <QString>
    #include <QNetworkAccessManager>
    #include <QObject>

    class MakeConn : public QObject
    {
    Q_OBJECT

    public:
    MakeConn(QObject* parent = 0);
    ~MakeConn();
    void addLayerName(const QString& layerName);
    void removeLayerName(const QString& layerName);
    ...
    private:
    QList<QString>layerNames;
    QString ipAddress, port;
    int width, height;
    QNetworkAccessManager* networkManager;
    QByteArray dataArray;

    signals:

    private slots:
    void finishedDownload();
    };@

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      If you are using .pro file - do you have such information

      @
      HEADERS += MakeConn .h
      @

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        Hi guziemic. MakeConn is the last one. I found out the solution. I declared this file before the main window and works.
        Thanks for reply.

        @
        QT += core gui network

        TARGET = MapReader
        TEMPLATE = app

        SOURCES += main.cpp
        mainwindow.cpp
        GeoMeasurements.cpp
        RasterMap.cpp
        MakeConn.cpp

        HEADERS += mainwindow.h
        GeoMeasurements.h
        RasterMap.h
        MakeConn.h

        FORMS += mainwindow.ui
        @

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          Your welcome :) If you could, please mark the post as solved by adding [solved] to title.

          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
          • Unsolved