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. error LNK2001: unresolved external symbol "public: static struct QMetaObject const BUtils
QtWS25 Last Chance

error LNK2001: unresolved external symbol "public: static struct QMetaObject const BUtils

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 2 Posters 6.4k Views
  • 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.
  • JoeCFDJ Offline
    JoeCFDJ Offline
    JoeCFD
    wrote on last edited by
    #1

    I have a small qt class BUtils with export definition. It is defined in one module BMesh(dll) and can be compiled in the module BMesh without issue in VIsual Studio. Then I use BUtils in another module(dll) TBase. I added qt libraries, BMesh.lib and include paths in the
    properties of module TBase. I started to recompile TBase and got the linking error:

    .obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const BUtils::staticMetaObject
    

    I have another static variable defined in BUtils and got the following error:
    .obj : error LNK2001: unresolved external symbol "public: static bool BUtils::m_bStop"
    It seems only related to static definition. I have another nonstatic funcion and there is no error message to complains about
    that one. What is wrong? Thanks for your help

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

      Hi,

      Can you show how you exported your class ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • JoeCFDJ Offline
        JoeCFDJ Offline
        JoeCFD
        wrote on last edited by SGaist
        #3
        ============================Global.h==========================
        
        #ifndef GLOBAL_H
        #define GLOBAL_H
        
        #  ifndef Global_EXPORT
        #  define Global_EXPORT __declspec( dllexport )
        #endif
        
        ===========================BUtils.h===========================
        
        #ifndef BUtils_H
        #define BUtils_H
        
        #include "Global.h"
        #include <QtCore/QObject>
        
        class Global_EXPORT BUtils : public QObject
        {
            Q_OBJECT
            
        public:
            static bool m_bStop;
            
            void sendPercent( double percent );
        
        signals:
            void emitPercent( double );
        };
        
        #endif
        
        ===========================BUtils.cpp==================================
        
        #include "BUtils.h"
        
        bool BUtils::m_bStop = false;
        
        void BUtils::sendPercent( double percent )
        {
            emit emitPercent( percent );
        }
        

        [edit: Added missing coding tags SGaist]

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Ok, you only did half the work regarding symbol handling. There's exporting and importing symbols on Windows.

          You can find a nice example on how to do that in the Creating Shared Libraries chapter of Qt's documentation

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • JoeCFDJ Offline
            JoeCFDJ Offline
            JoeCFD
            wrote on last edited by
            #5

            Got it. Thanks a lot

            Joe

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              You're welcome !

              Since you have it working now, please mark the thread as solved using the "Topic Tool" button so that other forum users may know a solution has been found :)

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • JoeCFDJ Offline
                JoeCFDJ Offline
                JoeCFD
                wrote on last edited by
                #7

                Vielen Dank!

                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