Page 1 of 1

QxService Tutorial, MSVC ,_QX_STATIC_BUILD

PostPosted: Fri Jan 22, 2016 4:54 pm
by SteveW
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.

Re: QxService Tutorial, MSVC ,_QX_STATIC_BUILD

PostPosted: Sat Jan 23, 2016 8:31 am
by qxorm
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...