Building SQLite DLL with Visual Studio 2015

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Building SQLite DLL with Visual Studio 2015

John Smith
Hi,


I need to build a data-layer DLL for a large project.

My project is 64-bit built with Visual-Studio 2015.

I want to ask about  what would be the preferred way to build SQLite:

1. Build SQLite code as a separate DLL and use it from my data-layer DLL,

2. Use the ready-built binary of 64-bit SQLite DLL for Windows (sqlite-dll-win64-x64-3260000.zip),

3. Or, build my data-layer code with SQLite code as a single DLL.

Thanks in advanced,

John


_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Building SQLite DLL with Visual Studio 2015

J Decker
On Mon, Jan 21, 2019 at 2:16 AM John Smith <[hidden email]> wrote:

> Hi,
>
>
> I need to build a data-layer DLL for a large project.
>
> My project is 64-bit built with Visual-Studio 2015.
>
> I want to ask about  what would be the preferred way to build SQLite:
>
> 1. Build SQLite code as a separate DLL and use it from my data-layer DLL,
>
> 2. Use the ready-built binary of 64-bit SQLite DLL for Windows
> (sqlite-dll-win64-x64-3260000.zip),
>
> 3. Or, build my data-layer code with SQLite code as a single DLL.
>

4. Statically linked to and compiled with your datalayer code.


> Thanks in advanced,
>
> John
>
>
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Building SQLite DLL with Visual Studio 2015

Simon Slavin-3


On 21 Jan 2019, at 11:16am, J Decker <[hidden email]> wrote:

> 4. Statically linked to and compiled with your datalayer code.

What he said.  Also, you should be using the 'Amalgamation' download to do this, unless you need some compiler switches which are not supported by that source-set.

Simon.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Building SQLite DLL with Visual Studio 2015

Chris Locke-3
Just curious as to why you wouldn't choose option #2 - as that's what I use
with my VB .NET applications, which work quite well.  Just distribute the
.exe, then the two SQLite DLLs (well, three technically, as there are two
versions of the interop.dll)

Thanks,
Chris

On Mon, Jan 21, 2019 at 4:19 PM Simon Slavin <[hidden email]> wrote:

>
>
> On 21 Jan 2019, at 11:16am, J Decker <[hidden email]> wrote:
>
> > 4. Statically linked to and compiled with your datalayer code.
>
> What he said.  Also, you should be using the 'Amalgamation' download to do
> this, unless you need some compiler switches which are not supported by
> that source-set.
>
> Simon.
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Building SQLite DLL with Visual Studio 2015

Keith Medcalf
In reply to this post by John Smith

There are a few reasons for putting code in a DYNAMIC link library (linked at runtime) versus statically linked into the application (the same applies to all operating systems that support runtime linkage no matter what they call the runtime linked modules):

1)  You need to be able to replace the version of the DYNAMIC library code without rebuilding anything else

or

2)  You have multiple executables (A) (B) and (C) (for example) that will all use the same DYNAMIC library code and you are hard-up for memory such that you only want the DYNAMIC library code loaded once and used by all requestors in order to save memory.

or both.  Note that there is a third reason for using a dynamic (runtime) linked library and that is that it provides something that you want all comers to be able to use the same way.  Examples of this include the interfaces to the operating system and its platform libraries themselves which are always dynamically linked (this is the primary job of the program loader after all), and code which is "near to" such status such as widely used utility routines (such as zlib, X, etc).

You may use item (1) for example so that your application uses SQLite3 in a DLL.  Without making any change to your application at all, you can change the version of SQLite3 being used simply by changing the SQLite3.DLL.  This works well provided that the API contract does not change between versions of the DLL and that you are dependent on that API contract, not on the implementation details of the contract "under the hood" -- if it does (ie, you are version/implementation dependent) then you are in what is known as "DLL Hell" because your application is not actually dependent on the SQLite3 API, it is dependent on a certain VERSION of the SQLite3.DLL.  Mutatis mutandis to any DLL providing any API.

You may use item (2) for example so that your application uses a standard facility in a way that is compatible with item (1) in order to save loading the code into every process.  An example of this is the language/subsystem runtime libraries.  Since there may be many thousands of these executables running concurrently -- such as every single process requiring the use of the platform "C" library.  Rather than statically link the several megabytes of runtime into each and every executable (and loading A COPY of the same code with each executable), the library is only loaded ONCE and each process MAPS the loaded module into its own virtual address space thus perhaps saving gigabytes or terabytes of memory by only actually loading one copy of the code which everyone uses.

Putting something into a DLL "just cuz you can" is not a good reason for putting code in a DLL and unless you require the capabilities provided by (1) or (2) and are absolutely sure that you are dependent on the API contract and not the implementation contract, putting code in a DLL is almost always a bad idea.  It may be "cute" and "what the jonses are doing", but it serves no useful purpose other than add complication for complication sake.

That is to say that if you have to change anything other than just "copying over" the DLL to change the implementation of the API functionality that DLL provides to your application, then using a DLL was the wrong thing to do.

So, the only one who can answer your question is you by your knowledge of how your application works.

---
The fact that there's a Highway to Hell but only a Stairway to Heaven says a lot about anticipated traffic volume.

>-----Original Message-----
>From: sqlite-users [mailto:sqlite-users-
>[hidden email]] On Behalf Of John Smith
>Sent: Monday, 21 January, 2019 03:16
>To: SQLite mailing list
>Subject: [sqlite] Building SQLite DLL with Visual Studio 2015
>
>Hi,
>
>
>I need to build a data-layer DLL for a large project.
>
>My project is 64-bit built with Visual-Studio 2015.
>
>I want to ask about  what would be the preferred way to build SQLite:
>
>1. Build SQLite code as a separate DLL and use it from my data-layer
>DLL,
>
>2. Use the ready-built binary of 64-bit SQLite DLL for Windows
>(sqlite-dll-win64-x64-3260000.zip),
>
>3. Or, build my data-layer code with SQLite code as a single DLL.
>
>Thanks in advanced,
>
>John
>
>
>_______________________________________________
>sqlite-users mailing list
>[hidden email]
>http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users



_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users