stmt.c is already included, so you do not need to include it again.  To "turn 
on" the builtin stmt_vtab you need to add the preprocessor define:

SQLITE_ENABLE_STMTVTAB

There are a bunch of extensions and modules already included in the 
amalgamation sqlite3.c that you just need to "turn on" via preprocessor 
directives.

See 
https://www.sqlite.org/amalgamation.html
https://www.sqlite.org/compile.html

As for the compress extension it uses zlib.  So you have to have zlib compiled 
for your platform and compiler available on your system.  Generally this will 
be a static library of some type that you must include as a link library, and 
have the .h file somewhere in an included directory.  The static and dynamic 
libraries are included with all versions of the gcc compiler, you just have to 
tell the compiler to link it.  For other compilers the level of complication 
and bother to get something working will vary.


Useful hint:

You can put all your defines as normal statements in a file called config.h 
that lives in the same directory as the sqlite3.c source and "activate" that 
being included very early in sqlite3.c to configure the compilation by defining 
the preprocessor symbol:

_HAVE_SQLITE_CONFIG_H

That way, you do not have to define so many preprocessor macros to the compiler 
itself.  And you can fiddle with them easily.

config.h should look something like (you will notice that I configure a lot of 
stuff including different defaults depending on the compiler and model used -- 
since gcc supports everything and msvc is cannot even do floating point 
arithmetic worth a crap).  Note that when building from canonical sources the 
config.h is built by configure so you cannot use it for this purpose, but it 
works with the amalgamation compilation just fine:

---//--- snip ---//---
#ifndef _CONFIG_H
#define _CONFIG_H

// Values of WINVER and _WIN32_WINNT for various minimum levels of Win32 
Compatability
//
// WIN10    0x0A00      WIN6     0x0600      W2K      0x0500     NT4      0x0400
//                      VISTA    0x0600      WXP      0x0501     W95      0x0400
//                      W2K8     0x0600      W2K3     0x0502     NT4E     0x0401
//                      WIN7     0x0601                          W98      0x0410
//                      WIN8     0x0602                          WME      0x0490
//                      WIN81    0x0603

#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0600
#endif
#ifndef WINVER
#define WINVER _WIN32_WINNT
#endif

// *** SQLITE GENERAL CONFIGURATION OPTIONS ***

// #define SQLITE_DEFAULT_AUTOMATIC_INDEX      1               // default: 1
// #define SQLITE_DEFAULT_AUTOVACUUM           0               // default: 0

// Set Default Page Cache Size and Temp Cache Size based on Memory Model

#if defined(_WIN64)
#define SQLITE_DEFAULT_CACHE_SIZE          262144           // 1 GB
#define SQLITE_DEFAULT_TEMP_CACHE_SIZE     262144           // 1 GB default: 
500 pages
#else
#define SQLITE_DEFAULT_CACHE_SIZE           65536           // 256 MB
#define SQLITE_DEFAULT_TEMP_CACHE_SIZE      65536           // 256 MB default: 
500 pages
#endif

// #define SQLITE_DEFAULT_FILE_FORMAT          4               // default: 4
// #define SQLITE_DEFAULT_FILE_PERMISSIONS     0644            // default: 0644
#define SQLITE_DEFAULT_FOREIGN_KEYS         1               // default: 0
// #define SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT   4194304         // default: -1
// #define SQLITE_DEFAULT_LOCKING_MODE         0               // default: 0
// #define SQLITE_DEFAULT_MEMSTATUS            1               // default: 1
#define SQLITE_DEFAULT_PAGE_SIZE            4096            // default: 4096 
max: 65536
// #define SQLITE_DEFAULT_SYNCHRONOUS          2               // default: 2
// #define SQLITE_DEFAULT_WAL_SYNCHRONOUS      2               // default: same 
as default synchronous
// #define SQLITE_DEFAULT_WORKER_THREADS       4               // default: 0
#define SQLITE_DEFAULT_WAL_AUTOCHECKPOINT   256             // default: 1000 
pages
#define SQLITE_DEFAULT_PROXYDIR_PERMISSIONS 0755            // default: 0755
#define SQLITE_DEFAULT_RECURSIVE_TRIGGERS   1               // default: 0
#define SQLITE_DEFAULT_SHARED_CACHE         0               // default: 0
#define SQLITE_DEFAULT_MMAP_SIZE            0               // default: 0
// #define SQLITE_LIKE_DOESNT_MATCH_BLOBS      1               // default: 
undefined
// #define SQLITE_SORTER_PMASZ                 64              // default: 250
// #define SQLITE_EXTRA_DURABLE                1               // Extra 
DirSync's default not defined


// *** SQLITE FEATURE CONFIGURATION OPTIONS ***

#define SQLITE_ALLOW_COVERING_INDEX_SCAN 1
#define SQLITE_INTROSPECTION_PRAGMAS 1                      // Add 
Instropsection Pragmas
#define SQLITE_ENABLE_8_3_NAMES 1
// #define SQLITE_ENABLE_ATOMIC_WRITE 1
#define SQLITE_ENABLE_API_ARMOR 1                           // Enable API Armour
#define SQLITE_ENABLE_COLUMN_METADATA 1
#define SQLITE_ENABLE_COSTMULT 1
#define SQLITE_ENABLE_CURSOR_HINTS 1
#define SQLITE_COUNTOFVIEW_OPTIMIZATION 1
#define SQLITE_ENABLE_DBSTAT_VTAB 1
#define SQLITE_ENABLE_EXPLAIN_COMMENTS 1
#define SQLITE_ENABLE_FTS3 1
#define SQLITE_ENABLE_FTS3_PARENTHESIS 1
// #define SQLITE_DISABLE_FTS3_UNICODE 1
#define SQLITE_ENABLE_FTS4 1
#define SQLITE_ENABLE_FTS5 1
// #define SQLITE_ENABLE_ICU 1                                 // Set in BUILD 
Command additional Libs required
#define SQLITE_ENABLE_JSON1 1                               // Enable JSON1 -- 
when standard extension
#define SQLITE_ENABLE_LOAD_EXTENSION 1
#define SQLITE_ENABLE_LOCKING_STYLE 1
#define SQLITE_ENABLE_MEMORY_MANAGEMENT 1                   // Enable Memory 
Management (sqlite3_release_memory)
#define SQLITE_ENABLE_MEMSYS3 1
#define SQLITE_ENABLE_MEMSYS5 1
#define SQLITE_ENABLE_MODULE_COMMENTS 1
#define SQLITE_ENABLE_PREUPDATE_HOOK 1
// #define SQLITE_ENABLE_QPSG                                  // Enable Query 
Planner Stability Guarantee
#define SQLITE_ENABLE_RBU 1                                 // Enable Resumable 
Bulk Update
#define SQLITE_ENABLE_RTREE 1
// #define SQLITE_RTREE_INT_ONLY 1
#define SQLITE_ENABLE_SESSION 1                             // Enable the 
SESSION feature
// #define SQLITE_ENABLE_SNAPSHOT 1                            // Enable the 
SNAPSHOT feature
#define SQLITE_ENABLE_STAT_VTAB 1                           // Enable 
dbstat_register called from shell
#define SQLITE_ENABLE_STAT1 1
#define SQLITE_ENABLE_STAT2 1
#define SQLITE_ENABLE_STAT3 1
#define SQLITE_ENABLE_STAT4 1
#define SQLITE_ENABLE_STMTVTAB 1                            // Enable Stmt VTAB
#define SQLITE_ENABLE_UNIONVTAB 1                           // Enable unionvtab
// #define SQLITE_ENABLE_VFSSTAT 1                             // Enable 
vftstat extension
// #define SQLITE_LIKE_DOESNT_MATCH_BLOBS      1               // default: 0 
(undefined)
#define SQLITE_STAT4_SAMPLES 64                             // default: 24 
samples
// #define SQLITE_64BIT_STATS 1
// #define SQLITE_ENABLE_UNLOCK_NOTIFY 1                       // See 
Documentation before enabling
// #define SQLITE_ENABLE_UPDATE_DELETE_LIMIT 1                 // Requires 
Special Amalgamation / Parser Support
#define SQLITE_SOUNDEX 1
// #define SQLITE_DISABLE_LFS 1
// #define SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS 1
// #define SQLITE_DISABLE_DIRSYNC 1
// #define SQLITE_CASE_SENSITIVE_LIKE 1
// #define SQLITE_SECURE_DELETE 1
#define SQLITE_TEMP_STORE 2                                 // 0 = Files 
Always, 1 = Files, 2 = Memory, 3 Memory Always
#define SQLITE_USE_URI 1                                    // Enable URI 
Filenames
#define SQLITE_ALLOW_URI_AUTHORITY 1                        // Allow Authority 
(Host) in URI
// #define SQLITE_MMAP_READWRITE 1                             // mmaps are 
writeable as well as readable

//  *** SQLITE MAXIMUMS AND LIMITS CONFIGURATION ***

// #define SQLITE_FTS3_MAX_EXPR_DEPTH          15              // default: 12
#define SQLITE_MAX_ATTACHED                 15              // default: 10      
    max: 62
// #define SQLITE_MAX_COLUMN                   2000            // default: 2000 
       max: 32767
// #define SQLITE_MAX_COMPOUND_SELECT          500             // default: 500
// #define SQLITE_MAX_EXPR_DEPTH               1000            // default: 1000
// #define SQLITE_MAX_FUNCTION_ARG             100             // default: 100  
       max: 127
// #define SQLITE_MAX_LENGTH                   0x3fffffff      // default: 
1000000000  max: 2147483647 (2^31-1)
// #define SQLITE_MAX_LIKE_PATTERN_LENGTH      16384           // default: 50000
// #define SQLITE_MAX_MEMORY                   0               // default: 0
// #if defined(_WIN64)
// #define SQLITE_MAX_MEMORY                   4294967296      // 4 GB on x64
// #else
// #define SQLITE_MAX_MEMORY                   1073741824      // 1 GB on x32
// #endif
// #define SQLITE_MAX_MMAP_SIZE                0x7fff0000      // default: 
0x7fff0000
// #define SQLITE_MAX_PAGE_COUNT               1073741823      // default: 
1073741823  max: 2147483646 (2^31-2)
// #define SQLITE_MAX_SQL_LENGTH               131072          // default: 
1000000     max: 2^30
// #define SQLITE_MAX_TRIGGER_DEPTH            1000            // default: 1000
// #define SQLITE_MAX_VARIABLE_NUMBER          999             // default: 999
// #define SQLITE_MAX_SCHEMA_RETRY             50              // default: 50
// #define SQLITE_MAX_WORKER_THREADS           8               // default: 11
// #define YYSTACKDEPTH                        100             // defautl: 100

//  *** SQLITE OPERATING SYSTEM AND INTERNALS CONFIGURATION ***

//  #define SQLITE_OS_OTHER 0
#define SQLITE_OS_WIN 1
#define SQLITE_OS_WINNT 1
// #define SQLITE_OS_WINCE 1
// #define SQLITE_OS_WINRT 1
#define SQLITE_WIN32_MALLOC 1                               // Use Win32 Heap 
Allocator
// #define SQLITE_WIN32_HEAP_CREATE 1                          // Use Separate 
Win32 Heap
// #define SQLITE_WIN32_MALLOC_VALIDATE 1                      // Validate 
Win32 Heap during SQLITE_DEBUG assert
// #if defined(_WIN64)
// #define SQLITE_WIN32_HEAP_INIT_SIZE 1073741824              // Initial Win32 
Heap Size = 1 GB
// #else
// #define SQLITE_WIN32_HEAP_INIT_SIZE 268435456               // Initial Win32 
Heap Size = 256 MB
// #endif
// #define SQLITE_WIN32_HEAP_MAX_SIZE 0                        // Max Win32 
Heap Size (No Limit)
// #define SQLITE_WIN32_HEAP_FLAGS 0
// #define SQLITE_WIN32_FILE_WRITETHROUGH 1                    // Force Windows 
WRITE-THROUGH Behaviour
// #define SQLITE_DIRECT_OVERFLOW_READ 1                       // Do Not 
PageCache Overflow Pages
// #define SQLITE_DEFAULT_LOOKASIDE 1200,100                   // Default 
LookAside Allocation
// #define SQLITE_SYSTEM_MALLOC 1                              // Use Default 
System Heap (default if no other specified)
// #define SQLITE_MALLOC_SOFT_LIMIT 1024
// #define SQLITE_POWERSAFE_OVERWRITE 0
// #define SQLITE_4_BYTE_ALIGNED_MALLOC 1
// #define SQLITE_USE_ALLOCA 1                                 // Use AllocA to 
Allocate Parse object os Stack


// *** SQLITE OMIT FEATURES ***

// #define SQLITE_OMIT_ALTERTABLE
// #define SQLITE_OMIT_ANALYZE
// #define SQLITE_OMIT_ATTACH
// #define SQLITE_OMIT_AUTHORIZATION
// #define SQLITE_OMIT_AUTOINCREMENT
// #define SQLITE_OMIT_AUTOINIT
// #define SQLITE_OMIT_AUTOMATIC_INDEX
// #define SQLITE_OMIT_AUTORESET
// #define SQLITE_OMIT_AUTOVACUUM
// #define SQLITE_OMIT_BETWEEN_OPTIMIZATION
// #define SQLITE_OMIT_BLOB_LITERAL
// #define SQLITE_OMIT_BTREECOUNT
// #define SQLITE_OMIT_BUILTIN_TEST
// #define SQLITE_OMIT_CAST
// #define SQLITE_OMIT_CHECK
// #define SQLITE_OMIT_COMPILEOPTION_DIAGS
// #define SQLITE_OMIT_COMPLETE
// #define SQLITE_OMIT_COMPOUND_SELECT
// #define SQLITE_OMIT_DATETIME_FUNCS
// #define SQLITE_OMIT_DECLTYPE
// #define SQLITE_OMIT_DEPRECATED
// #define SQLITE_OMIT_DISKIO
// #define SQLITE_OMIT_EXPLAIN
// #define SQLITE_OMIT_FLAG_PRAGMAS
// #define SQLITE_OMIT_FLOATING_POINT
// #define SQLITE_OMIT_FOREIGN_KEY
// #define SQLITE_OMIT_GET_TABLE
// #define SQLITE_OMIT_INCRBLOB
// #define SQLITE_OMIT_INTEGRITY_CHECK
// #define SQLITE_OMIT_LIKE_OPTIMIZATION
// #define SQLITE_OMIT_LOAD_EXTENSION
// #define SQLITE_OMIT_LOCALTIME
// #define SQLITE_OMIT_LOOKASIDE
// #define SQLITE_OMIT_MEMORYDB
// #define SQLITE_OMIT_MERGE_SORT
// #define SQLITE_OMIT_OR_OPTIMIZATION
// #define SQLITE_OMIT_PAGER_PRAGMAS
// #define SQLITE_OMIT_PRAGMA
// #define SQLITE_OMIT_PROGRESS_CALLBACK
// #define SQLITE_OMIT_QUICKBALANCE
// #define SQLITE_OMIT_REINDEX
// #define SQLITE_OMIT_SCHEMA_PRAGMAS
// #define SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS
// #define SQLITE_OMIT_SHARED_CACHE
// #define SQLITE_OMIT_SHUTDOWN_DIRECTORIES
// #define SQLITE_OMIT_SUBQUERY
// #define SQLITE_OMIT_TCL_VARIABLE
// #define SQLITE_OMIT_TEMPDB
// #define SQLITE_OMIT_TRACE
// #define SQLITE_OMIT_TRIGGER
// #define SQLITE_OMIT_TRUNCATE_OPTIMIZATION
// #define SQLITE_OMIT_UTF16
// #define SQLITE_OMIT_VACUUM
// #define SQLITE_OMIT_VIEW
// #define SQLITE_OMIT_VIRTUALTABLE
// #define SQLITE_OMIT_WAL
// #define SQLITE_OMIT_WSD
// #define SQLITE_OMIT_XFER_OPT

// *** SQLITE DEBUGGING FEATURES ***

// #define SQLITE_DEBUG 1
// #define SQLITE_ENABLE_EXPENSIVE_ASSERT 1
// #define SQLITE_ENABLE_OVERSIZE_CELL_CHECK 1
// #define SQLITE_ENABLE_SELECTTRACE 1                         // Enable Select 
Trace (.selecttrace 0x100) needs SQLITE_DEBUG
// #define SQLITE_ENABLE_SQLLOG 1                              // Enable 
SQLITE_CONFIG_SQLLOG (see documentation)
// #define SQLITE_ENABLE_STMT_SCANSTATUS 1                     // Enable 
Collection of Statement Scan Status
// #define SQLITE_ENABLE_WHERETRACE 1
// #define SQLITE_IOTRACE 1
// #define SQLITE_MEMDEBUG 1
// #define SQLITE_REVERSE_UNORDERED_SELECTS 1
// #define SQLITE_USE_FCNTL_TRACE 1                            // Enable extra 
vfslog fcntrl trace
// #define SQLITE_YYTRACKMAXSTACKDEPTH 1


// *** Custom Additions ***

#define SQLITE_NOW_STABILITY_STMT 1                         // Make 'now' 
stable within a statement, not only for a step
// #define SQLITE_WIN32_FILE_SEQUENTIAL 1                      // Force Windows 
SEQUENTIAL access cache behaviour
#define SQLITE_WIN32_FILE_RANDOM 1                          // Force Windows 
RANDOM access cache behaviour
#define WHERE_PATH_SIMPLE 50                                // Paths to 
remember for  2-way joins
#define WHERE_PATH_COMPLEX 100                              // Paths to 
remember for >2-way joins
#define SQLITE_USE_QUADMATH 1                               // Use 128-bit 
Float Intermediates if available

// Recommended Optimizations

// #define SQLITE_THREADSAFE                   0                   // Remove 
Thread Safety Mutexes
// #define SQLITE_DEFAULT_MEMSTATUS            0                   // Remove 
Memory Status from SQLITE3_MALLOC
#define SQLITE_DEFAULT_WAL_SYNCHRONOUS      1                   // Reduce 
Synchronous to NORMAL in WAL mode
#define SQLITE_LIKE_DOESNT_MATCH_BLOBS      1                   // Disable LIKE 
matching for BLOBS
// #define SQLITE_MAX_EXPR_DEPTH               0                   // Disable 
Parser Depth Checking
// #define SQLITE_OMIT_DECLTYPE                1                   // Omit 
Declaration Type from Cursors
// #define SQLITE_OMIT_DEPRECATED              1                   // Omit 
Deprecated Code
// #define SQLITE_OMIT_PROGRESS_CALLBACK       1                   // Omit 
Progress Callback loop counter
// #define SQLITE_OMIT_SHARED_CACHE            1                   // Omit 
Shared Cache

// Compiler and Platform specifics

#define HAVE_FDATASYNC 1
#define HAVE_GMTIME_R 1
#define HAVE_LOCALTIME_S 1
#define HAVE_USLEEP 1
#define HAVE_UTIME 1
#define HAVE_MALLOC_USABLE_SIZE 1

#if defined(_WIN32) && defined(__GNUC__)
#define UNICODE_STRING_MAX_BYTES ((WORD)65534)
#define UNICODE_STRING_MAX_CHARS (32766)
#define HAVE_ISNAN 1
#endif

#if defined(__GNUC__) && defined(SQLITE_USE_QUADMATH)
#define LONGDOUBLE_TYPE __float128
#endif
#endif
---//-- snip --//--

and that is how I end up with this after building the shell:

SQLite version 3.21.0 2017-08-25 13:34:18
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> pragma compile_options;
ALLOW_COVERING_INDEX_SCAN
ALLOW_URI_AUTHORITY
COMPILER=gcc-7.1.0
DEFAULT_CACHE_SIZE=262144
DEFAULT_FOREIGN_KEYS
DEFAULT_MMAP_SIZE=0
DEFAULT_PAGE_SIZE=4096
DEFAULT_PROXYDIR_PERMISSIONS=0755
DEFAULT_RECURSIVE_TRIGGERS
DEFAULT_WAL_AUTOCHECKPOINT=256
DEFAULT_WAL_SYNCHRONOUS=1
ENABLE_8_3_NAMES=1
ENABLE_API_ARMOR
ENABLE_COLUMN_METADATA
ENABLE_COSTMULT
ENABLE_CURSOR_HINTS
ENABLE_DBSTAT_VTAB
ENABLE_FTS3
ENABLE_FTS3_PARENTHESIS
ENABLE_FTS4
ENABLE_FTS5
ENABLE_JSON1
ENABLE_LOAD_EXTENSION
ENABLE_LOCKING_STYLE=1
ENABLE_MEMORY_MANAGEMENT
ENABLE_MEMSYS3
ENABLE_MEMSYS5
ENABLE_PREUPDATE_HOOK
ENABLE_RBU
ENABLE_RTREE
ENABLE_SESSION
ENABLE_STAT4
ENABLE_STMTVTAB
EXTRA_INIT=core_init
HAVE_ISNAN
LIKE_DOESNT_MATCH_BLOBS
MAX_ATTACHED=15
SOUNDEX
STAT4_SAMPLES=64
TEMP_STORE=2
THREADSAFE=1
USE_URI
WIN32_MALLOC

(the EXTRA_INIT being set separately so I can build an "unmodified" version 
without all the extra extensions for debugging ..)

---
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-
>boun...@mailinglists.sqlite.org] On Behalf Of curmudgeon
>Sent: Friday, 25 August, 2017 07:41
>To: sqlite-users@mailinglists.sqlite.org
>Subject: Re: [sqlite] Compiling spellfix for sqlite3
>
>While testing I appended the following code to the end of sqlite3.c.
>
>#include "csv.c"
>#include "stmt.c"
>#include "compress.c"
>#include "eval.c"
>#include "carray.c"
>
>int core_init(const char* dummy)
>{
>       int nErr = 0;
>       nErr +=
>sqlite3_auto_extension((void(*)())sqlite3_compress_init);
>       nErr += sqlite3_auto_extension((void(*)())sqlite3_eval_init);
>#ifndef SQLITE_OMIT_VIRTUALTABLE
>       nErr += sqlite3_auto_extension((void(*)())sqlite3_csv_init);
>       nErr += sqlite3_auto_extension((void(*)())sqlite3_stmt_init);
>       nErr += sqlite3_auto_extension((void(*)())sqlite3_carray_init);
>#endif
>       return nErr ? SQLITE_ERROR : SQLITE_OK;
>}
>
>
>My compiler gave the following errors/warnings.
>
>[bcc32 Error] csv.c(42): E2209 Unable to open include file
>'sqlite3ext.h'
>I fixed this error by changing <sqlite3ext.h> to "sqlite3ext.h"
>
>[bcc32 Error] sqlite3.c(204450): E2451 Undefined symbol
>'sqlite3_stmt_init'
>Not sure if this is to do with the fact that stmt.c is already
>present in
>sqlite3.c
>
>[bcc32 Error] compress.c(18): E2209 Unable to open include file
>'zlib.h'
>Above error appears even if I change <zlib.h> to "zlib.h"
>[bcc32 Warning] compress.c(54): W8065 Call to function 'compress'
>with no
>prototype
>[bcc32 Error] compress.c(55): E2451 Undefined symbol 'Z_OK'
>[bcc32 Warning] compress.c(87): W8065 Call to function 'uncompress'
>with no
>prototype
>[bcc32 Error] compress.c(88): E2451 Undefined symbol 'Z_OK'
>
>
>
>
>
>
>--
>View this message in context:
>http://sqlite.1065341.n5.nabble.com/Compiling-spellfix-for-sqlite3-
>tp70656p97100.html
>Sent from the SQLite mailing list archive at Nabble.com.
>_______________________________________________
>sqlite-users mailing list
>sqlite-users@mailinglists.sqlite.org
>http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users



_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to