On 10/05/16 10:42, Andrey Gorbachev wrote:
> I am a bit worried that the initialisation of 2 different versions of SQLite 
> would interfere with one another. Any advice?

There is a way to do it, and I use it for my Python APSW extension as
the recommended build instructions.  It is especially helpful on MacOS
as system components like Core Data use SQLite, and the loaders tend to
force the system SQLite library to always be loaded.  As a bonus, the
approach below also results in faster code.

What you need to do is create a .c file that near the top has these lines:

    #define SQLITE_API     static
    #define SQLITE_EXTERN  static
    #include "sqlite3.c"

That causes all the SQLite non-private symbols to only have the scope of
that .c file, and not leak outside of it.

In the rest of the .c file put your C code that uses the SQLite API, and
it will use the static included version (only).

You are done.  The reason this also gives faster code is that the
compiler can inline the heck out of SQLite code since it knows it won't
be used outside of the compilation unit.  It does sometimes make
debugging interesting though.

Roger

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: OpenPGP digital signature
URL: 
<http://mailinglists.sqlite.org/cgi-bin/mailman/private/sqlite-users/attachments/20160510/8d7552f7/attachment.pgp>

Reply via email to