[odb-users] Error creating multi-database query support code with objects containing composite values in Visual Studio 2010/2013 (MSVC)

Harald Frostel Harald.Frostel at jku.at
Wed Jan 15 09:26:03 EST 2014


Hi!
 
I have a problem creating dynamic multi-database query support code with objects that contain composite value members under Visual Studio (MSVC) 2010 and 2013.
 
I created a minimal example to shown the problem with MSVC and SQLite. The same code compiles and runs without problems under Linux/GCC and Apple/Clang.
 
The architecture is as follows (similar to the ODB Manual):
- The common layer code is compiled into a shared library (model.dll).
- The generated sqlite (or any other) layer code (model-odb-sqlite.cxx, ...) is compiled into model-sqlite.dll and linked against the common layer shared library.
- The program (testprogram) links agains the common layer and loads the sqlite layer at runtime.
 
This works without problems for database objects that does not contain composite value members or if no query code is generated.
If query code is generated, the linking of the sqlite layer code fails due to unresolved external symbols (under MSVC) for the composite value types.
The linking error goes away for some reason, if the database object also contains columns of plain datatypes (e.g. ints) but than the testprogram craches at runtime if a query for that object is executed.
 
To make things easy, the attached minimal example can be build using cmake. I tried the code unter Visual Studio Express 2013 (64 bit compiler) and Visual Studio Express 2010 (32-bit code) and both fail. Under Linux/GCC and Mac/Clang the example works (odb-2.3.0)
 
I'm not sure if this is a bug in odb (2.3.0) or I'm getting something wrong with the EXPORT/EXTERN macros.
 
To test the program simply run cmake and make, and than execute the testprogram binary (if linking works). To remove the linking error of the sqlite shared library code, simply go to line number 87 in model.hxx, remove the comments and watch the testprogram fail.
 
Code: http://www.cp.jku.at/people/frostel/MinimalCompositeTest.zip
 
I hope, somebody can give me any advice!
 
Regards
Harald
 

 
****************************************************
Dipl.-Ing. Harald Frostel
Department of Computational Perception
Johannes Kepler University Linz
Altenberger Strasse 69
A-4040 Linz, Austria	    
 
Tel:  +43 732 2468 1521
Fax:  +43 732 2468 1520
Mail: harald.frostel at jku.at
http://www.cp.jku.at/people/frostel
****************************************************


More information about the odb-users mailing list