error LNK2001: unresolved external symbol "public: static struct QMetaObject const BUtils
-
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 -
Hi,
Can you show how you exported your class ?
-
============================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]
-
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
-
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 :)