MOC error LNK2019 for QMetaObject when import/export
-
I am getting unresolved external symbols for all the parts of code where QMetaObject is used. I think its because import/export definitions.
I am generating bindings using shiboken and in my cmakelist I am using AutoGenerateHeader which is different from other examples where they add just a macro.h header that takes care of import/export. So my current problem is that the headerExport is generated and defined for can_library, but I link the can_library to a different one later one at which point i need to be using or better to say I need to redefine the exportHeader contents to switch to import if I'm thiniking correct. it has something to do with my MOC and those lines i added below, because when I take away e.g
BUSINTERFACES_EXPORT="__declspec(dllexport)"I get 1 less error.this are the errors (i am getting more but only posting 2 for better oversight):
main.cpp.obj:-1: error: LNK2019: unresolved external symbol "public: static struct QMetaObject const sky::SlipSocket::staticMetaObject" (?staticMetaObject@SlipSocket@sky@@2UQMetaObject@@B) referenced in function "public: static class QMetaObject::Connection __cdecl QObject::connect<void (__cdecl sky::SlipSocket::*)(void),class <lambda_0c11d8c4eede9ab6435c1f6184ee5490> >(class sky::SlipSocket const *,void (__cdecl sky::SlipSocket::*)(void),class QObject const *,class <lambda_0c11d8c4eede9ab6435c1f6184ee5490>,enum Qt::ConnectionType)" (??$connect@P8SlipSocket@sky@@EAAXXZV<lambda_0c11d8c4eede9ab6435c1f6184ee5490>@@@QObject@@SA?AVConnection@QMetaObject@@PEBVSlipSocket@sky@@P834@EAAXXZPEBV0@V<lambda_0c11d8c4eede9ab6435c1f6184ee5490>@@W4ConnectionType@Qt@@@Z) main.cpp.obj:-1: error: LNK2019: unresolved external symbol "public: static struct QMetaObject const sky::CanBase::staticMetaObject" (?staticMetaObject@CanBase@sky@@2UQMetaObject@@B) referenced in function "public: static class QMetaObject::Connection __cdecl QObject::connect<void (__cdecl sky::CanBase::*)(unsigned char,unsigned char),class <lambda_ecb641ebc5819cdfec4b5da2d7cd6f0e> >(class sky::CanBase const *,void (__cdecl sky::CanBase::*)(unsigned char,unsigned char),class QObject const *,class <lambda_ecb641ebc5819cdfec4b5da2d7cd6f0e>,enum Qt::ConnectionType)" (??$connect@P8CanBase@sky@@EAAXEE@ZV<lambda_ecb641ebc5819cdfec4b5da2d7cd6f0e>@@@QObject@@SA?AVConnection@QMetaObject@@PEBVCanBase@sky@@P834@EAAXEE@ZPEBV0@V<lambda_ecb641ebc5819cdfec4b5da2d7cd6f0e>@@W4ConnectionType@Qt@@@Z)I set my target_compile_definitions for can_library and bindings like this :
if(BUILD_SHARED_LIBS) target_compile_definitions(${can_library} PRIVATE BUSINTERFACES_EXPORT="__declspec(dllexport)" CANBASE_EXPORT="__declspec(dllexport)" CANOPEN2_EXPORT="__declspec(dllexport)" SOFTWARE_FRAMEWORK_EXPORT="__declspec(dllexport)" CANTS_EXPORT="__declspec(dllexport)" ) target_compile_definitions(${bindings_library} INTERFACE BUSINTERFACES_EXPORT="__declspec(dllimport)" CANBASE_EXPORT="__declspec(dllimport)" CANOPEN2_EXPORT="__declspec(dllimport)" SOFTWARE_FRAMEWORK_EXPORT="__declspec(dllimport)" CANTS_EXPORT="__declspec(dllimport)" ) else() target_compile_definitions(${can_library} PRIVATE BUSINTERFACES_EXPORT="" CANBASE_EXPORT="" CANOPEN2_EXPORT="" SOFTWARE_FRAMEWORK_EXPORT="" CANTS_EXPORT="" ) target_compile_definitions(${bindings_library} PRIVATE BUSINTERFACES_EXPORT="" CANBASE_EXPORT="" CANOPEN2_EXPORT="" SOFTWARE_FRAMEWORK_EXPORT="" CANTS_EXPORT="" ) endif() target_link_libraries(${bindings_library} PRIVATE ${can_library})each of those names e.g. BUSINTERFACES_EXPORT is a GenerateExportHeaders macro:
#define BUSINTERFACES_EXPORT_H #ifdef BUSINTERFACES_BUILT_AS_STATIC # define BUSINTERFACES_EXPORT # define BUSINTERFACES_NO_EXPORT #else # ifndef BUSINTERFACES_EXPORT # ifdef businterfaces_EXPORTS /* We are building this library */ # define BUSINTERFACES_EXPORT __declspec(dllexport) # else /* We are using this library */ # define BUSINTERFACES_EXPORT __declspec(dllimport) # endif # endif # ifndef BUSINTERFACES_NO_EXPORT # define BUSINTERFACES_NO_EXPORT # endif #endif #ifndef BUSINTERFACES_DEPRECATED # define BUSINTERFACES_DEPRECATED __declspec(deprecated) #endif #ifndef BUSINTERFACES_DEPRECATED_EXPORT # define BUSINTERFACES_DEPRECATED_EXPORT BUSINTERFACES_EXPORT BUSINTERFACES_DEPRECATED #endif #ifndef BUSINTERFACES_DEPRECATED_NO_EXPORT # define BUSINTERFACES_DEPRECATED_NO_EXPORT BUSINTERFACES_NO_EXPORT BUSINTERFACES_DEPRECATED #endif #if 0 /* DEFINE_NO_DEPRECATED */ # ifndef BUSINTERFACES_NO_DEPRECATED # define BUSINTERFACES_NO_DEPRECATED # endif #endif #endif /* BUSINTERFACES_EXPORT_H */ -
K kikijoko has marked this topic as solved on