[odb-users] Using ODB from DLL on Windows XP

Leo Ashkinaziy Leo_Ashkinaziy at symantec.com
Thu Jun 30 21:51:52 EDT 2016


Hi Boris,

Thank you. That worked. I pretty much pasted libodb/odb/details/win32/dll.cxx into our DllMain() and that worked for the DLL. For the ConsoleApp I call process_start() and thread_start() in the start of main() and thread_end() and process_end() at the end. I'm assuming that's the correct thing to do?

--
Leo

-----Original Message-----
From: Boris Kolpackov [mailto:boris at codesynthesis.com] 
Sent: Wednesday, June 29, 2016 11:49 PM
To: Leo Ashkinaziy <Leo_Ashkinaziy at symantec.com>
Cc: odb-users at codesynthesis.com
Subject: Re: [odb-users] Using ODB from DLL on Windows XP

Hi Leo,

Leo Ashkinaziy <Leo_Ashkinaziy at symantec.com> writes:

> * Change configuration type to static library
> * Change preprocessor defines where appropriate to LIBODB_SQLITE_STATIC_LIB,
>   LIBODB_BOOST_STATIC_LIB, and LIBODB_STATIC_LIB

Ok, now we get the missing piece of the puzzle: you not only disabled the use of the declspec(thread), but you also made all the ODB libraries static. This is the lethal combination ;-).

When you disable declspec(thread), ODB has to emulate POSIX-like TLS support and for that it needs to allocate some data structures at process/thread startup. When libodb is built as a DLL, it does all this automatically from DllMain(). For a static library, however, you will need to do this manually (which is also the reason why we don't provide static build configurations).

In your case, the easiest will probably be to replicate the calls found in libodb/odb/details/win32/dll.cxx in your DynLib.dll's DllMain().

Boris



More information about the odb-users mailing list