Details
-
Suggestion
-
Resolution: Out of scope
-
P3: Somewhat important
-
4.1.0
-
None
Description
Exporting a C++ class using DEF files has certain advantages (allows cyclic dependencies between DLLs; faster link time when using ordinals; smaller DLLs), and is in general possible by using the decorated names of all functions.
Qt 4 requires a variable to be exported, ie. the staticMetaObject variable of each Q_OBJECT class. MSDN documents that variables can be exported via DEF files using the DATA keyword, but have to be imported using __declspec(dllimport). If __declspec(dllimport) is not used, then the address of the variable is not resolved correctly, and this crashes in calls to QMetaObject.
Using __declspec(dllimport) however duplicates the effort exporting, and makes the DEF files less useful.
If the staticMetaObject variable would be accessed through a function (like in Qt 3), then this would work without problems.