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. [Solved] error LNK2001: unresolved external symbol
Forum Updated to NodeBB v4.3 + New Features

[Solved] error LNK2001: unresolved external symbol

Scheduled Pinned Locked Moved General and Desktop
13 Posts 3 Posters 26.2k 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.
  • S Offline
    S Offline
    silep
    wrote on last edited by
    #3

    Yeah that's right at the beginning for the moc generation there is

    @errorMsg.h(13): Note: No relevant classes found. No output generated.@

    But I really don't know how to fix it.

    NB: the file is well included in the .pro file

    1 Reply Last reply
    0
    • JohanSoloJ Offline
      JohanSoloJ Offline
      JohanSolo
      wrote on last edited by JohanSolo
      #4

      Did you put the Q_OBJECT macro at the beginning of your class declaration? E.g:

      class errorMsg : [...]
      {
          Q_OBJECT
      

      `They did not know it was impossible, so they did it.'
      -- Mark Twain

      1 Reply Last reply
      0
      • S Offline
        S Offline
        silep
        wrote on last edited by
        #5

        Yes I did

        1 Reply Last reply
        0
        • JohanSoloJ Offline
          JohanSoloJ Offline
          JohanSolo
          wrote on last edited by
          #6

          What does you errorMsg class declaration look like?

          `They did not know it was impossible, so they did it.'
          -- Mark Twain

          1 Reply Last reply
          0
          • S Offline
            S Offline
            silep
            wrote on last edited by
            #7

            @#ifndef ERRORMSG_H
            #define ERRORMSG_H

            class errorMsg : public QObject
            {
            Q_OBJECT

            public:
            errorMsg();
            ~errorMsg();
            void writeErrorMsg(QString msg, int value);

            };

            #endif //ERRORMSG_H@

            1 Reply Last reply
            0
            • JohanSoloJ Offline
              JohanSoloJ Offline
              JohanSolo
              wrote on last edited by JohanSolo
              #8

              Apart from the

              -errorMsg();
              

              which I assume is a typo, this looks almost OK. You seem to be missing the

              #include <QtCore/QObject>
              

              directive.

              `They did not know it was impossible, so they did it.'
              -- Mark Twain

              1 Reply Last reply
              0
              • S Offline
                S Offline
                silep
                wrote on last edited by
                #9

                The "~errorMsg();" is the destructor, but it is not so usefull.

                I added your include line but it didn't change anything.

                My includes are

                @#include <QString>
                #include <QFile>
                #include <QTextStream>
                #include <iostream>
                #include <QDateTime>
                #include <QLabel>
                #include <QTextEdit>
                #include <QtCore/QObject>
                #include "mainform.h"@

                1 Reply Last reply
                0
                • JohanSoloJ Offline
                  JohanSoloJ Offline
                  JohanSolo
                  wrote on last edited by
                  #10

                  [quote author="bern69" date="1396621287"]The "~errorMsg();" is the destructor, but it is not so usefull.
                  [/quote]
                  Obviously, but the "-" should read as a "~"...

                  Indeed the include I told you to add is not needed since many widgets are already included.

                  I guess you've already tried to rerun qmake and it didn't change a thing.

                  Could you provide your (complete) .pro file?

                  Edit: is it only me who sees the tilda as an hyphen?

                  `They did not know it was impossible, so they did it.'
                  -- Mark Twain

                  1 Reply Last reply
                  0
                  • B Offline
                    B Offline
                    bodzio131
                    wrote on last edited by
                    #11

                    Why would you like to build your errorMsg with Q_OBJECT if you don't declare any signals/slots inside it nor use other Qt's meta-object system services?

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      silep
                      wrote on last edited by
                      #12

                      I removed Q_OBJECT from the class and it works now! Thank you very much! I inserted it because I will program some signals and slots later. If I understand, I have to keep it as commentary until the first slot is inserted?

                      1 Reply Last reply
                      1
                      • B Offline
                        B Offline
                        bodzio131
                        wrote on last edited by
                        #13

                        Yes. I don't understand why moc doesn't generate an empty .moc file and some warnings in such case, but it's how it works.

                        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