Compile wxSQLite with encryption and linkingSQLite3.dll sta Topic is solved

Talk here about issues with one of the components hosted at wxCode, or suggest features for it.
User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2104
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania
Contact:

Compile wxSQLite with encryption and linkingSQLite3.dll sta

Post by evstevemd » Sat Mar 13, 2010 7:31 am

I can do the DLL version of SQLite3 and have wxSQLite3 as static. I want to compile all things as static so I don't know what include folders and .cpp I need to include. Note *encryption* support.

Thanks
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
[Ubuntu 15.04/Windows 10 Pro - GCC/MinGW, CodeLite IDE et al]

utelle
Moderator
Moderator
Posts: 842
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: Compile wxSQLite with encryption and linkingSQLite3.dll

Post by utelle » Sat Mar 13, 2010 2:28 pm

evstevemd wrote:I can do the DLL version of SQLite3 and have wxSQLite3 as static. I want to compile all things as static so I don't know what include folders and .cpp I need to include. Note *encryption* support.
Download the SQLite amalgamation source code from the SQLite download site and copy the sources into subdirectory sqlite3/secure/src/codec-c. Then create a project for compiling SQLite as a static library using your favorite IDE. Add file sqlite3secure.c as the only source file to your project. This file includes all other required source files.

You need to specify several preprocessor symbols to get a valid SQLite library.

The following 2 symbols enable encryption support:

SQLITE_HAS_CODEC
CODEC_TYPE=CODEC_TYPE_AES128

In the latter symbol you may specify CODEC_TYPE_AES256 instead of CODEC_TYPE_AES128 to enable the (experimental) support for AES 256 bit encryption.

The following 2 symbols are usually always required resp. recommended:

SQLITE_CORE
THREADSAFE=1

The following 3 symbols are optional to enable specific SQLite features:

SQLITE_SECURE_DELETE
SQLITE_SOUNDEX
SQLITE_ENABLE_COLUMN_METADATA

The following 3 symbols enable optional extension modules:

SQLITE_ENABLE_FTS3
SQLITE_ENABLE_FTS3_PARENTHESIS
SQLITE_ENABLE_RTREE

On Windows, copy the resulting static library file sqlite3.lib to subdirectory sqlite3/lib and create wxSQLite3 as usual.

For other platforms the required steps might vary slightly.

Regards,

Ulrich

User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2104
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania
Contact:

Post by evstevemd » Sun Mar 14, 2010 9:23 pm

Thanks Urlich!
Crystal clear :wink:
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
[Ubuntu 15.04/Windows 10 Pro - GCC/MinGW, CodeLite IDE et al]

User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2104
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania
Contact:

Re: Compile wxSQLite with encryption and linkingSQLite3.dll

Post by evstevemd » Mon Mar 15, 2010 10:13 pm

utelle wrote:
evstevemd wrote:I can do the DLL version of SQLite3 and have wxSQLite3 as static. I want to compile all things as static so I don't know what include folders and .cpp I need to include. Note *encryption* support.
Download the SQLite amalgamation source code from the SQLite download site and copy the sources into subdirectory sqlite3/secure/src/codec-c. Then create a project for compiling SQLite as a static library using your favorite IDE. Add file sqlite3secure.c as the only source file to your project. This file includes all other required source files.

You need to specify several preprocessor symbols to get a valid SQLite library.

The following 2 symbols enable encryption support:

SQLITE_HAS_CODEC
CODEC_TYPE=CODEC_TYPE_AES128

In the latter symbol you may specify CODEC_TYPE_AES256 instead of CODEC_TYPE_AES128 to enable the (experimental) support for AES 256 bit encryption.

The following 2 symbols are usually always required resp. recommended:

SQLITE_CORE
THREADSAFE=1

The following 3 symbols are optional to enable specific SQLite features:

SQLITE_SECURE_DELETE
SQLITE_SOUNDEX
SQLITE_ENABLE_COLUMN_METADATA

The following 3 symbols enable optional extension modules:

SQLITE_ENABLE_FTS3
SQLITE_ENABLE_FTS3_PARENTHESIS
SQLITE_ENABLE_RTREE

On Windows, copy the resulting static library file sqlite3.lib to subdirectory sqlite3/lib and create wxSQLite3 as usual.

For other platforms the required steps might vary slightly.

Regards,

Ulrich
I'm confused as to where I put those macros. Do I put them in sqlite3secure.c? and if yes, do I put something like this?

Code: Select all

#ifndef SQLITE_HAS_CODEC
#define
#ifndef CODEC_TYPE=CODEC_TYPE_AES128
#define CODEC_TYPE=CODEC_TYPE_AES128
#endif
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
[Ubuntu 15.04/Windows 10 Pro - GCC/MinGW, CodeLite IDE et al]

utelle
Moderator
Moderator
Posts: 842
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: Compile wxSQLite with encryption and linkingSQLite3.dll

Post by utelle » Tue Mar 16, 2010 7:03 am

evstevemd wrote:I'm confused as to where I put those macros. Do I put them in sqlite3secure.c? and if yes, do I put something like this?

Code: Select all

#ifndef SQLITE_HAS_CODEC
#define
#ifndef CODEC_TYPE=CODEC_TYPE_AES128
#define CODEC_TYPE=CODEC_TYPE_AES128
#endif
Those preprocessor symbols have to appear on the compiler's command line. Usually each IDE has a compiler options dialog somewhere, where you can specify preprocessor symbols.

Alternatively you could place #define statements right at the beginning of sqlite3secure.c, but I wouldn't recommend to do so.

Regards,

Ulrich

User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2104
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania
Contact:

Re: Compile wxSQLite with encryption and linkingSQLite3.dll

Post by evstevemd » Tue Mar 16, 2010 10:18 pm

utelle wrote:
evstevemd wrote:I'm confused as to where I put those macros. Do I put them in sqlite3secure.c? and if yes, do I put something like this?

Code: Select all

#ifndef SQLITE_HAS_CODEC
#define
#ifndef CODEC_TYPE=CODEC_TYPE_AES128
#define CODEC_TYPE=CODEC_TYPE_AES128
#endif
Those preprocessor symbols have to appear on the compiler's command line. Usually each IDE has a compiler options dialog somewhere, where you can specify preprocessor symbols.

Alternatively you could place #define statements right at the beginning of sqlite3secure.c, but I wouldn't recommend to do so.

Regards,

Ulrich
I use CodeLite and Hope Eran will help on this. I will dig to see what I can do.
Thanks Urlich for your usual support on wxSQLite
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
[Ubuntu 15.04/Windows 10 Pro - GCC/MinGW, CodeLite IDE et al]

User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2104
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania
Contact:

Post by evstevemd » Wed Jun 09, 2010 4:21 pm

I decided to add for codeliters.
Right click project then go to properties. Click compiler tab and look for preprocessor. You can type in the Macros separating with semicolon or click button and get the dialog where each preprocessor goes in new line

Hope others will do it!
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
[Ubuntu 15.04/Windows 10 Pro - GCC/MinGW, CodeLite IDE et al]

User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2104
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania
Contact:

Post by evstevemd » Sun Sep 05, 2010 4:08 pm

Hi,
I try to use below settings and I tried without defining them and I got library file and works. When I the preprocessors below I get errors quoted below!

Here are preprocessor directives
SQLITE_CORE
THREADSAFE=1
SQLITE_HAS_CODEC
CODEC_TYPE=CODEC_TYPE_AES128
SQLITE_SECURE_DELETE
SQLITE_SOUNDEX
SQLITE_ENABLE_COLUMN_METADATA
SQLITE_ENABLE_FTS3
SQLITE_ENABLE_FTS3_PARENTHESIS
SQLITE_ENABLE_RTREE

here are errors:

In file included from C:/Documents and Settings/smtangoo/Desktop/CodeLite/HosannaNeno/sqlite3/sqlite3secure.c:50:
C:/Documents and Settings/smtangoo/Desktop/CodeLite/HosannaNeno/sqlite3/codecext.c: In function 'sqlite3_rekey':
C:/Documents and Settings/smtangoo/Desktop/CodeLite/HosannaNeno/sqlite3/codecext.c:250: error: void value not ignored as it ought to be
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
[Ubuntu 15.04/Windows 10 Pro - GCC/MinGW, CodeLite IDE et al]

utelle
Moderator
Moderator
Posts: 842
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Post by utelle » Tue Sep 07, 2010 9:52 am

evstevemd wrote:I try to use below settings and I tried without defining them and I got library file and works. When I the preprocessors below I get errors quoted below!

Here are preprocessor directives
SQLITE_CORE
THREADSAFE=1
SQLITE_HAS_CODEC
CODEC_TYPE=CODEC_TYPE_AES128
SQLITE_SECURE_DELETE
SQLITE_SOUNDEX
SQLITE_ENABLE_COLUMN_METADATA
SQLITE_ENABLE_FTS3
SQLITE_ENABLE_FTS3_PARENTHESIS
SQLITE_ENABLE_RTREE

here are errors:
In file included from C:/Documents and Settings/smtangoo/Desktop/CodeLite/HosannaNeno/sqlite3/sqlite3secure.c:50:
C:/Documents and Settings/smtangoo/Desktop/CodeLite/HosannaNeno/sqlite3/codecext.c: In function 'sqlite3_rekey':
C:/Documents and Settings/smtangoo/Desktop/CodeLite/HosannaNeno/sqlite3/codecext.c:250: error: void value not ignored as it ought to be
If you try to compile the latest SQLite version 3.7.2 you have to get the latest version of codecext.c first from the wxCode SVN. There were changes in the internal SQLite pager interface.

Regards,

Ulrich

User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2104
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania
Contact:

Post by evstevemd » Wed Sep 08, 2010 5:27 am

utelle wrote:
evstevemd wrote:I try to use below settings and I tried without defining them and I got library file and works. When I the preprocessors below I get errors quoted below!

Here are preprocessor directives
SQLITE_CORE
THREADSAFE=1
SQLITE_HAS_CODEC
CODEC_TYPE=CODEC_TYPE_AES128
SQLITE_SECURE_DELETE
SQLITE_SOUNDEX
SQLITE_ENABLE_COLUMN_METADATA
SQLITE_ENABLE_FTS3
SQLITE_ENABLE_FTS3_PARENTHESIS
SQLITE_ENABLE_RTREE

here are errors:
In file included from C:/Documents and Settings/smtangoo/Desktop/CodeLite/HosannaNeno/sqlite3/sqlite3secure.c:50:
C:/Documents and Settings/smtangoo/Desktop/CodeLite/HosannaNeno/sqlite3/codecext.c: In function 'sqlite3_rekey':
C:/Documents and Settings/smtangoo/Desktop/CodeLite/HosannaNeno/sqlite3/codecext.c:250: error: void value not ignored as it ought to be
If you try to compile the latest SQLite version 3.7.2 you have to get the latest version of codecext.c first from the wxCode SVN. There were changes in the internal SQLite pager interface.

Regards,

Ulrich
Thanks a lot. I will check out
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
[Ubuntu 15.04/Windows 10 Pro - GCC/MinGW, CodeLite IDE et al]

qarahat
In need of some credit
In need of some credit
Posts: 2
Joined: Tue Feb 22, 2011 2:16 pm

Re: Compile wxSQLite with encryption and linkingSQLite3.dll

Post by qarahat » Tue Feb 22, 2011 3:11 pm

utelle wrote: Download the SQLite amalgamation source code from the SQLite download site and copy the sources into subdirectory sqlite3/secure/src/codec-c. Then create a project for compiling SQLite as a static library using your favorite IDE. Add file sqlite3secure.c as the only source file to your project. This file includes all other required source files.
utelle, I tried to follow the steps you provided, and it seemed to me that everything compiled and linked well. I wrote a few lines of code to check whether this encryption support is working, but I'm getting exceptions there. Here is my code:

Code: Select all

wxSQLite3Database* db;
	
try
{
	wxString dbName = wxGetCwd() + wxT("/simple.db");		
	db = new wxSQLite3Database();				
	db->Open(dbName);		
	db->ReKey(wxT("somePassword"));

	wxSQLite3ResultSet set = db->ExecuteQuery(wxT("SELECT * FROM sample_table"));

	if (set.NextRow())
	{
		wxString s = set.GetAsString(1);
		wxMessageBox(s);
	}
	set.Finalize();

}
catch(wxSQLite3Exception ex)
{
	wxMessageBox(ex.GetMessage());
}
So I'm getting
  • UNKNOWN_ERROR[-1]: error getting symbol <sqlite3_backup_init>
  • Couldn't find symbol 'sqlite3_backup_init' in a dynamic library (error 127: the specified procedure couldn't be found.)
exceptions when code reaches

Code: Select all

db->Open(dbName);
line. It seems for me that according to last exception some files are missing in the library, but I'm not sure. Your advice to solve the problem would be precious. Thanks in advance.

utelle
Moderator
Moderator
Posts: 842
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: Compile wxSQLite with encryption and linkingSQLite3.dll

Post by utelle » Tue Feb 22, 2011 9:00 pm

qarahat wrote:utelle, I tried to follow the steps you provided, and it seemed to me that everything compiled and linked well. I wrote a few lines of code to check whether this encryption support is working, but I'm getting exceptions there. Here is my code:

Code: Select all

wxSQLite3Database* db;
	
try
{
	wxString dbName = wxGetCwd() + wxT("/simple.db");		
	db = new wxSQLite3Database();				
	db->Open(dbName);		
	db->ReKey(wxT("somePassword"));

	wxSQLite3ResultSet set = db->ExecuteQuery(wxT("SELECT * FROM sample_table"));

	if (set.NextRow())
	{
		wxString s = set.GetAsString(1);
		wxMessageBox(s);
	}
	set.Finalize();

}
catch(wxSQLite3Exception ex)
{
	wxMessageBox(ex.GetMessage());
}
So I'm getting
  • UNKNOWN_ERROR[-1]: error getting symbol <sqlite3_backup_init>
  • Couldn't find symbol 'sqlite3_backup_init' in a dynamic library (error 127: the specified procedure couldn't be found.)
exceptions when code reaches

Code: Select all

db->Open(dbName);
line. It seems for me that according to last exception some files are missing in the library, but I'm not sure. Your advice to solve the problem would be precious. Thanks in advance.
Your code is certainly not the problem. It's the SQLite DLL your application tries to load. It seems you compiled wxSQLite3 against a newer version of SQLite than is found at runtime. Make sure the SQLite DLL matching the version you used to build wxSQLite3 is found first on the search path of your system.

Regards,

Ulrich

qarahat
In need of some credit
In need of some credit
Posts: 2
Joined: Tue Feb 22, 2011 2:16 pm

Re: Compile wxSQLite with encryption and linkingSQLite3.dll

Post by qarahat » Wed Feb 23, 2011 8:27 am

utelle wrote: Your code is certainly not the problem. It's the SQLite DLL your application tries to load. It seems you compiled wxSQLite3 against a newer version of SQLite than is found at runtime. Make sure the SQLite DLL matching the version you used to build wxSQLite3 is found first on the search path of your system.

Regards,

Ulrich
Thanks, Ulrich. I found what was the problem, while compiling wxSQLite3 I used USE_DYNAMIC_SQLITE3_LOAD equals to 1 which was wrong, and after setting that preprocessor to 0, everything worked fine. Today I noticed that everything is clearly described in wxSQLite3's readme file, sorry for disturbing you, instead I could check doc's more carefully :-). Thanks a lot.

User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2104
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania
Contact:

Post by evstevemd » Wed Feb 23, 2011 10:57 am

The maximum support this man provides plus Quality library is why I still love using wxSQLite3.
Thanks Urlich! :D
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
[Ubuntu 15.04/Windows 10 Pro - GCC/MinGW, CodeLite IDE et al]

silverstorm82
Knows some wx things
Knows some wx things
Posts: 32
Joined: Wed Aug 17, 2011 5:13 pm

Re: Compile wxSQLite with encryption and linkingSQLite3.dll

Post by silverstorm82 » Thu Dec 01, 2011 3:06 pm

I am sorry to ask again for help here.

I used the sqlite3.lib/.dll in the /sqlite3/secure subfolder and copied the files to sqlite3/lib subdirectory and compiled wxSQLite3. But HasEncryptionSupport() still returns false and when using ReKey() an exception is thrown ("Encryption support not available").

Any ideas here? If I understood correctly the preprocessor symbols

SQLITE_HAS_CODEC
CODEC_TYPE=CODEC_TYPE_AES128
SQLITE_CORE
THREADSAFE=1

have to be set when wxSQLite ist compiled, which I did. As the explanation in the readme is not very clear about where to set the symbols exactly, could you provide a detailled description please?

Greetings,
Jens

Post Reply