[odb-users] MSVC19 Linker error when deriving from an ORM object in another DLL

CETONI GmbH - Uwe Kindler uwe.kindler at cetoni.de
Tue Jul 9 05:02:27 EDT 2024


Hi,

We are switching from MinGW compiler to MSVC19 compiler and see linker 
errors, when deriving an ORM object from an ORM object in a different DLL.

The first DLL *qtlabb_items.dl*l contains the following ORM objects:

PositionableItem.h

#pragmadb model version(1, 1)

#pragmadb object abstract

classQTLABB_ITEMS_EXPORTCPositionableItem

{

private:

friendclassodb::access;///< allow ODB ORM to access out private members

#pragmadb id auto

longm_Id;

#pragmadb transient

CPositionableItem* m_Parent;///< points to parent container (0 if no parent)

doublem_CenterX;

doublem_CenterY;

doublem_CenterZ;

doublem_Rotation;

#pragmadb transient

mutableQtLabb::CTransformm_Transform;///< transformation matrix

#pragmadb transient

mutableDatabase::COdbSqliteDatabase* m_Database;///< reference to the 
database where this item is stored

Container.h

#pragmadb object abstract

classQTLABB_ITEMS_EXPORTCContainer: publicCPositionableItem

{

protected:

friendclassodb::access;///< allow ODB ORM to access to private members

doublem_SizeX;///< length of this container

doublem_SizeY;///< width of this container

doublem_Height;///< the height of this container

QStringm_Name;///< the container name

unsignedintm_ColorARGB; ///< color of this well plate

RowColumnContainer.h

/**

* A CRowColumnContainer is an abstraction of a container that has a 
number of

* equal child containers arranged in rows and columns.

* I.e. a well plate is a kind of CRowColumnContainer

*/

#pragmadb model version(1, 1)

#pragmadb object abstract

classQTLABB_ITEMS_EXPORTCRowColumnContainer: publicCContainer

{

protected:

friendclassodb::access;///< allow ODB ORM to access to private members

intm_RowCount;///< number of cavity rows of this container

doublem_RowSpacing;///< row spacing - the space between centers of two 
cavities

intm_ColumnCount;///< number of cavity columns of this container

doublem_ColumnSpacing;///< column spacing

RowColumnContainer.h (derived from CContainer)

The second DLL *qtlabb_fluidhandling.dll* containes the following ORM object

PipetteStore.h (derived from CRowColumnContainer):

#pragmadb model version(1, 1)

#pragmadb object

classQTLABB_FLUIDHANDLING_EXPORTCPipetteStore: publicCRowColumnContainer

{

private:

friendclassodb::access;///< allow ODB ORM to access to private members

/**

* Default constructor for ORM

*/

CPipetteStore();

/**

* Private constructor called from public constructors

*/

voidprivConstructor(CPipetteStoreParamsconst* Params = 0);

protected:

#pragmadb transient

PipetteStorePrivate* d;///< private transient data of pipettestore

QVector<bool> m_SlotFilledStates;///< for ORM filled state of all slots

When compiling the qtlabb_fluidhandling.dll, we see a number of linker 
errors in the PipetteStore-odb.obj file compiled from 
PipetteStore-odb.cpp generated from ODB compiler:

PipetteStore-odb.obj : error LNK2019: Verweis auf nicht aufgelöstes 
externes Symbol ""public: static long __cdecl 
odb::access::object_traits_impl<class 
QtLabb::CPositionableItem,1>::id(struct 
odb::access::object_traits_impl<class 
QtLabb::CPositionableItem,1>::id_image_type const &)" 
(?id@?$object_traits_impl at VCPositionableItem@QtLabb@@$00 at access@odb@@SAJAEBUid_image_type at 123@@Z)" 
in Funktion ""public: static long __cdecl 
odb::access::object_traits_impl<class 
QtLabb::CPipetteStore,1>::id(struct 
odb::access::object_traits_impl<class 
QtLabb::CPositionableItem,1>::id_image_type const &)" 
(?id@?$object_traits_impl at VCPipetteStore@QtLabb@@$00 at access@odb@@SAJAEBUid_image_type@?$object_traits_impl at VCPositionableItem@QtLabb@@$00 at 23@@Z)".

I can solve this issue by manually adding QTLABB_ITEMS_EXPORT macros to 
the static class members but I'm not sure, if it is the right way to 
manually add export macros to a generated file. What is the right way to 
properly export the data generated by ORM compiler.

Thank you,

Uwe






More information about the odb-users mailing list