Documentation Source Text
Check-in [cec1821adef52267e0f14471a227396fb3ec2667]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
SHA1 Hash:cec1821adef52267e0f14471a227396fb3ec2667
Date: 2014-05-28 19:37:03
User: drh
Comment:Add instructions on building DLLs to the howtocompile.html page.
Tags And Properties
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to pages/howtocompile.in

224
225
226
227
228
229
230


























































<p>The "sqlite3.c" make target will automatically construct the regular
"<b>sqlite3.c</b>" amalgamation source file, its header file
"<b>sqlite3.h</b>", and the "<b>tclsqlite3.c</b>" amalgamation source
file that includes the TCL interface.
Afterwards, the needed files can be copied into project directories and
compiled according to the procedures outlined above.</p>
































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287

<p>The "sqlite3.c" make target will automatically construct the regular
"<b>sqlite3.c</b>" amalgamation source file, its header file
"<b>sqlite3.h</b>", and the "<b>tclsqlite3.c</b>" amalgamation source
file that includes the TCL interface.
Afterwards, the needed files can be copied into project directories and
compiled according to the procedures outlined above.</p>

<tcl>hd_fragment {dll} {building a DLL}</tcl>
<h2>Building A Windows DLL</h2>

<p>To build a DLL of SQLite for use in Windows, first acquire the
appropriate amalgamated source code files, sqlite3.c and sqlite3.h.  
These can either
be downloaded from the [http://www.sqlite.org/download.html | SQLite website]
or custom generated from sources as shown above.</p>

<p>With source code files in the working directory, a DLL
can be generated using MSVC with the following command:

<blockquote><pre>
cl sqlite3.c -link -dll -out:sqlite3.dll
</pre></blockquote>

<p>The above command should be run from the MSVC Native Tools Command
Prompt.  If you have MSVC installed on your machine, you probably
have multiple versions of this Command Prompt, for native builds
for x86 and x64, and possibly also for cross-compiling to ARM.
Use the appropriate Command Prompt depending on the desired DLL.</p>

<p>If using the MinGW compiler, the command-line is this:

<blockquote><pre>
gcc -shared sqlite3.c -o sqlite3.dll
</pre></blockquote>

<p>Note that MinGW generates 32-bit DLLs only.  There is a separate
MinGW64 project that can be used to generate 64-bit DLLs.  Presumably
the command-line syntax is similar.
Also note that recent versions of MSVC generate DLLs that will not work
on WinXP and earlier versions of Windows.  So for maximum compatibility
of your generated DLL, MinGW is recommended.  A good rule-of-thumb
is to generate 32-bit DLLs using MinGW and 64-bit DLLs using MSVC.

<p>In most cases, you will want to supplement the basic commands above with
[compile-time options] appropriate for your application.  Commonly used
compile-time options include:

<ul>
<li><p><b>-Os</b> - Optimize for size. 
Make the DLL as small as possible.</p>

<li><p><b>-O2</b> - Optimize for speed.  This will make the DLL larger by
unrolling loops and inlining functions.</p>

<li><p><b>-DSQLITE_ENABLE_FTS4</b> -
Include the [full-text search] engine code in SQLite.

<li><p><b>-DSQLITE_ENABLE_RTREE</b> - Include the [R-Tree extension].

<li><p><b>-DSQLITE_ENABLE_COLUMN_METADATA</b> -
This enables some extra APIs that are required by some common systems,
including Ruby-on-Rails.
</ul>