Compile sqlite3 with Rad Studio possible?

This forum is reserved for everything you want to talk about. It could be about programming, opinions, open source programs, development in general, or just cool stuff to share!
Post Reply
Django
In need of some credit
In need of some credit
Posts: 4
Joined: Fri Sep 11, 2015 3:05 pm

Compile sqlite3 with Rad Studio possible?

Post by Django »

Hello. I want create a LIB from sqlite3 with Rad Studio 2009.

I create a new static library project and copy all files from wxsqlite3-3.2.1\sqlite3\secure\src\* into it. Additional I add this defines
THREADSAFE=1
SQLITE_SOUNDEX
SQLITE_ENABLE_COLUMN_METADATA
SQLITE_HAS_CODEC
CODEC_TYPE=CODEC_TYPE_AES128
SQLITE_SECURE_DELETE
SQLITE_ENABLE_FTS3
SQLITE_ENABLE_FTS3_PARENTHESIS
SQLITE_ENABLE_RTREE
SQLITE_ENABLE_EXTFUNC
SQLITE_USE_URI
After press "compile" I get this error message:
"[BCC32 Fehler] codec.h(65): E2139 In Deklaration fehlt ;"
Line 65:

Code: Select all

Btree*        m_bt; /* Pointer to B-tree used by DB */
the next error is:
"[BCC32 Fehler] codec.h(66): E2451 Undefiniertes Symbol 'SQLITE_MAX_PAGE_SIZE'" (means "SQLITE_MAX_PAGE_SIZE'" is undefined)

Code: Select all

unsigned char m_page[SQLITE_MAX_PAGE_SIZE+24];
Is here somthing missing? :)
utelle
Moderator
Moderator
Posts: 1125
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: Compile sqlite3 with Rad Studio possible?

Post by utelle »

Django wrote:Hello. I want create a LIB from sqlite3 with Rad Studio 2009.
Although your question is not wxWidgets or wxCode related, I'm nevertheless going to answer it. :-)
Django wrote:I create a new static library project and copy all files from wxsqlite3-3.2.1\sqlite3\secure\src\* into it. Additional I add this defines
THREADSAFE=1
SQLITE_SOUNDEX
SQLITE_ENABLE_COLUMN_METADATA
SQLITE_HAS_CODEC
CODEC_TYPE=CODEC_TYPE_AES128
SQLITE_SECURE_DELETE
SQLITE_ENABLE_FTS3
SQLITE_ENABLE_FTS3_PARENTHESIS
SQLITE_ENABLE_RTREE
SQLITE_ENABLE_EXTFUNC
SQLITE_USE_URI
Up to here all looks fine. The subdirectory sqlite3/secure/src contains all source files required to build the SQLite3 library.
Django wrote:After press "compile" I get this error message:
"[BCC32 Fehler] codec.h(65): E2139 In Deklaration fehlt ;"
Line 65:

Code: Select all

Btree*        m_bt; /* Pointer to B-tree used by DB */
the next error is:
"[BCC32 Fehler] codec.h(66): E2451 Undefiniertes Symbol 'SQLITE_MAX_PAGE_SIZE'" (means "SQLITE_MAX_PAGE_SIZE'" is undefined)

Code: Select all

unsigned char m_page[SQLITE_MAX_PAGE_SIZE+24];
Is here somthing missing? :)
No, nothing is missing. You just have to start the compilation in the right way. Obviously you added all source files to your rad studio project. However, this will not work. The compiler will try to compile each source file separately. And this gives you the above error messages. The only source file you have to compile is sqlite3secure.c. This source file includes all other required files.

There is one small change you will have to apply to file sqlite3secure.c to make it compile without errors. Change line 10 to make it look like the following line:

Code: Select all

#define SQLITE_USER_AUTHENTICATION 1
Regards,

Ulrich
Django
In need of some credit
In need of some credit
Posts: 4
Joined: Fri Sep 11, 2015 3:05 pm

Re: Compile sqlite3 with Rad Studio possible?

Post by Django »

Big thanks for your help and great work here! ;)

I have remove directives from GUI and add after

Code: Select all

#define SQLITE_USER_AUTHENTICATION 1
this lines

Code: Select all

#define THREADSAFE 1
#define SQLITE_SOUNDEX 1
#define SQLITE_ENABLE_COLUMN_METADATA 1
#define SQLITE_HAS_CODEC 1
#define CODEC_TYPE CODEC_TYPE_AES128
#define SQLITE_SECURE_DELETE 1
#define SQLITE_ENABLE_FTS3 1
#define SQLITE_ENABLE_FTS3_PARENTHESIS 1
#define SQLITE_ENABLE_RTREE 1
//#define SQLITE_ENABLE_EXTFUNC 1 <<< removed, get still type error
#define SQLITE_USE_URI 1
Result: I get a LIB (496KB). My old version (6 years ago was 960KB). After include this LIB in my old application I get "sqlite3_key()" is now a unknown function. "sqlite_open()" working fine. Are you here an idea? ;)
utelle
Moderator
Moderator
Posts: 1125
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: Compile sqlite3 with Rad Studio possible?

Post by utelle »

Django wrote:I have remove directives from GUI and add after

Code: Select all

#define SQLITE_USER_AUTHENTICATION 1
this lines

Code: Select all

#define THREADSAFE 1
#define SQLITE_SOUNDEX 1
#define SQLITE_ENABLE_COLUMN_METADATA 1
#define SQLITE_HAS_CODEC 1
#define CODEC_TYPE CODEC_TYPE_AES128
#define SQLITE_SECURE_DELETE 1
#define SQLITE_ENABLE_FTS3 1
#define SQLITE_ENABLE_FTS3_PARENTHESIS 1
#define SQLITE_ENABLE_RTREE 1
//#define SQLITE_ENABLE_EXTFUNC 1 <<< removed, get still type error
#define SQLITE_USE_URI 1
If you add all these defines directly in the source code, you should do that immediately at the beginning of the file. For example, the symbol SQLITE_ENABLE_EXTFUNC is used on the 2nd line of sqlite3secure.c. If you are defining it later you are looking for trouble.
Django wrote:Result: I get a LIB (496KB). My old version (6 years ago was 960KB). After include this LIB in my old application I get "sqlite3_key()" is now a unknown function. "sqlite_open()" working fine. Are you here an idea? ;)
I'm not a clairvoyant, but my guess is that you added the defines too late in the source file. All defines have to be made at least before the file sqlite3.c is included. Probably this explains also the way too small size of the created libary.

Regards,

Ulrich
Django
In need of some credit
In need of some credit
Posts: 4
Joined: Fri Sep 11, 2015 3:05 pm

Re: Compile sqlite3 with Rad Studio possible?

Post by Django »

Thanks for your help. Working now fine. :)
Django
In need of some credit
In need of some credit
Posts: 4
Joined: Fri Sep 11, 2015 3:05 pm

Re: Compile sqlite3 with Rad Studio possible?

Post by Django »

Hello. Maybe you can help me again? ;)

I found that UPDATE not working with LIMIT in default setting of sqlite3. But its possible to enable it with compiling said this doc:
http://sqlite.org/compile.html#enable_u ... lete_limit

So I add

Code: Select all

#define SQLITE_ENABLE_UPDATE_DELETE_LIMIT 1
after

Code: Select all

#define SQLITE_CORE 1
But using LIMIT in UPDATE throw still a error. Must I set this line in another file or position?

You version 3.3 working fine with sqlite3 version 3110100. Thanks you very much. :)
utelle
Moderator
Moderator
Posts: 1125
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: Compile sqlite3 with Rad Studio possible?

Post by utelle »

Django wrote:I found that UPDATE not working with LIMIT in default setting of sqlite3. But its possible to enable it with compiling said this doc:
http://sqlite.org/compile.html#enable_u ... lete_limit
Well, enabling this SQL syntax in SQLite will not be a trivial task, since this feature is not enabled by default.

According to the SQLite documentation of this option
SQLITE_ENABLE_UPDATE_DELETE_LIMIT

This option enables an optional ORDER BY and LIMIT clause on UPDATE and DELETE statements.

If this option is defined, then it must also be defined when using the 'lemon' tool to generate a parse.c file. Because of this, this option may only be used when the library is built from source, not from the amalgamation or from the collection of pre-packaged C files provided for non-Unix like platforms on the website.
you need to compile SQLite from its original sources, you can't use the amalgamation. Sorry, you will be on your own, if you really need this SQL feature (which is non-standard by the way).

I would strongly recommend to avoid the use of the non-standard features ORDER BY and/or LIMIT in UPDATE or DELETE statements.
Django wrote:You version 3.3 working fine with sqlite3 version 3110100. Thanks you very much. :)
Good to hear.

Regards,

Ulrich
Post Reply