SQLite Forum

SQLite3 Extension
Login
> How do I overcome this?

You want to be producing a DLL, not an executable.  Tell Visual Studio to make it thus.  I have no idea how you do this in the clickety-pokey.

 > How can I include the source code into the 3.34.0 amalgamation so that I have the extension incorporated?

Simply append it to the end of the amalgamation file.  The real problem is how you get the init function called.  The easiest way (to me at any rate) is to append a function (after the extensions you want to add are all appended) that adds the init function for each extension to the auto extension list for new connections, and set the pre-processor symbol SQLITE_EXTRA_INIT to the name of this function.  I have no idea how you do this in the clickety-pokey.

An example SQLITE_EXTRA_INIT function looks like this:

```
int core_init(const char* dummy)
{
    int nErr = 0;

    nErr += sqlite3_auto_extension((void*)sqlite3_autobusy_init);
    nErr += sqlite3_auto_extension((void*)sqlite3_ipaddress_init);

    return nErr ? SQLITE_ERROR : SQLITE_OK;
}
```

so you would then define `SQLITE_EXTRA_INIT=core_init` when compiling the amalgamation code and the extensions would thereafter be automatically initialized on each connection.

The sqlite3_initialize function defined in main.c will call SQLITE_EXTRA_INIT function if the define is defined as the last step of the environment initialization process.  

If you do something in the EXTRA_INIT function that needs to be shutdown then you can also provide a function to clean that up by defining SQLITE_EXTRA_SHUTDOWN to be the name of that function, which will be called first when the sqlite3_shutdown API is called.  (You do not need to reset the auto extension list -- it is already done for you.)