QxService Tutorial, MSVC ,_QX_STATIC_BUILD

Forum for posting problems using QxOrm library

QxService Tutorial, MSVC ,_QX_STATIC_BUILD

Postby SteveW » Fri Jan 22, 2016 4:54 pm

Hi,

(I have _QX_STATIC_BUILD enabled as part of my reasearch/learning)

I hit unresolved external linker errors when building the QxServer application as it could not find the exports from the QxServiceServer DLL...(This only happens under MSVC compiler, MinGW is ok)

Looking into the problem a bit deeper, the QxServiceServer classes (eg "user_manager") are declared as QX_SERVICE_DLL_EXPORT, which resolves to QX_DLL_EXPORT_HELPER, which then resolves to "__declspec(dllexport)" as you would expect. And then when including the QxService headers in QxServer, the classes are declared as QX_SERVICE_DLL_IMPORT and hence QX_DLL_IMPORT_HELPER and then "__declspec(dllimport)". So far so good...

But then later down in QxMacro.h, there is the block of code...

Code: Select all
#ifdef _QX_STATIC_BUILD
#undef QX_DLL_EXPORT_HELPER
#undef QX_DLL_IMPORT_HELPER
#define QX_DLL_EXPORT_HELPER /* Nothing */
#define QX_DLL_IMPORT_HELPER /* Nothing */
#endif // _QX_STATIC_BUILD


(And the corresponding IMPORT equivalent).

...which then cancels out any import/export class declarations. Resulting in nothing being imported/exported from the QxService/QxServer EXE/DLL.

I can understand why this is done for internal Qx classes, but not external app classes such as the ones in QxService.

If I define my own "QX_APP_DLL_EXPORT/IMPORT_HELPER" marcos and define the QxService classes with those, the MSVC project builds and runs fine.

Have I got the wrong end of the stick here regarding the use of QX_STATIC_BUILD, and should the QxService tutorial be fundamentally not compatible with static libs? (It runs ok with my mods, but I havent done the full Server/Client runtime testing so far).

Thanks
Steve.
SteveW
 
Posts: 53
Joined: Tue Jan 19, 2016 4:12 pm

Re: QxService Tutorial, MSVC ,_QX_STATIC_BUILD

Postby qxorm » Sat Jan 23, 2016 8:31 am

Hello,

QxOrm library is designed to be used as a shared library, not a static library.
There is the _QX_STATIC_BUILD compilation option to force QxOrm library as a static library : but this option is not tested on each version.
So this is normal if you find some issues with the projects samples (because not tested as static lib).

So I recommend to use QxOrm library as a shared library.
But if you really want to use it as a static lib, then you have to test it.
Redefine the IMPORT/EXPORT macro seems OK for me, but you have to check if everything else is working fine...
qxorm
Site Admin
 
Posts: 481
Joined: Mon Apr 12, 2010 7:45 am


Return to QxOrm - Help

Who is online

Users browsing this forum: No registered users and 17 guests