Here are the steps I have followed to port it to Harbour: (My System is Vista Ultimate, HMG 3.0.40)
If you do not want to know about the build procedure and straightaway use SQLCipher you can go to step 12.
1. Downloaded SQLCipher Source code from here. https://github.com/sqlcipher/sqlcipher/tarball/v2.0.3 This version is based on SQLite version 3.7.9) in c:\sqlcipher
2. Downloaded and installed MingW + Msys latest version from http://sourceforge.net/projects/mingw/f ... urce=files in c:\mingw
3. Downloaded and installed ActiveState TCL from http://www.activestate.com/activetcl/downloads in c:\tcl
TCL is not required for SQLite as such. But MingW & MSys requires TCL to generate some c codes. It requires AWK too. But MingW installation includes AWK. So, there is no problem once you install Mingw + MSys.
4. Downloaded and installed OpenSSL from http://www.slproweb.com/products/Win32OpenSSL.html in c:\openssl
5. Copied c:\openssl\include\openssl folder to c:\mingw\include\openssl
6. Copied c:\openssl\lib\mingw\libeay32.a to c:\mingw\msys\1.0 (This is not required, but I have done for easy path)
7. Opened Command prompt. Set path to mingw and msys using the following commands, changed directory to SQLCipher and opened shell:
Code: Select all
c:\>path=%path%;c:\mingw\bin;c:\mingw\msys\1.0\bin
c:\>cd sqlcipher
c:\sqlcipher>sh
[code]
7. Run configure script as mentioned in SQLCipher site as below in the shell prompt as instructed in SQLCipher.net:
[code]
./configure --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC" LDFLAGS="libeay32.a"
[/code]
make
[/code]
This command would create many files including amalgamated single sqlite3.c and sqlite3.h
The make command gave many errors, I could not trace out but we need not worry about this as we require only sqlite3.c and sqlite3.h as above.
9. Created a directory sqlcipher inside Harbour folder. Copied sqlite3.c and sqlite3.h to this folder. Copied c:\openssl\lib\libeay32.a to c:\hmg.3.0.40\lib folder for having openssl at the time of application building.
10. Created the following hbc and hbp files:
sqlcipher.hbp file.
Code: Select all
#
# $Id: sqlite3.hbp 16257 2011-02-09 12:47:35Z vszakats $
#
-stop{hbdyn}
-stop{poccarm}
# NOTE: old msvcarm can't cope with some PP directives. [vszakats]
-stop{msvcarm&HB_COMP_VER!='1200'&HB_COMP_VER!='1300'&HB_COMP_VER!='1310')}
# NOTE: dos based watcom runs out of memory. [vszakats]
-stop{HB_HOST_PLAT='dos'&watcom}
# NOTE: disable *nix builds on non-*nix platforms; [vszakats]
# except for cygwin-on-win
-stop{!(HB_HOST_PLAT='win'&cygwin)&HB_HOST_PLAT_UNIX=''&unix}
-hblib
-inc
-o${hb_targetname}
-warn=low
-cpp=no
-cflag=-DSQLITE_HAS_CODEC
-cflag=-DSQLITE_OMIT_DEPRECATED
-cflag=-DSQLITE_ENABLE_COLUMN_METADATA
-cflag=-D_WIN32_WCE{wce}
# DJGPP and OpenWatcom in DOS aren't correctly recognized by SQLite,
# so we're forcing the next best available option. This will cause missing
# externals though. [vszakats]
-cflag=-DSQLITE_OS_OTHER{dos}
# Watcom Linux builds cannot use system header files
-cflag=-DSQLITE_OS_OTHER{linux&watcom}
-cflag=-DSQLITE_THREADSAFE=0{minix}
-cflag=-DSQLITE_OMIT_LOAD_EXTENSION=1{minix}
sqlite3.c
Code: Select all
#
# $Id: sqlite3.hbc 16215 2011-02-05 15:53:17Z vszakats $
#
libs=${hb_name}
cflags=-DSQLITE_OMIT_LOAD_EXTENSION=1{minix}
Code: Select all
SET HMGPATH=\hmg.3.0.40
SET PATH=%HMGPATH%\harbour\bin;%HMGPATH%\mingw\bin;%PATH%
hbmk2 sqlcipher.hbp -i%hmgpath%\include
12. Created a sample hmg application to find out whether everything is fine:
sample.prg
Code: Select all
#include <hmg.ch>
Function Main
local oDB := nil
local cKey := 'password123'
local cFile := 'sample.sqlite'
local aTable := {}
if file( cFile )
oDB := connect2db( 'sample.sqlite', .f. )
if oDB == Nil
msgstop( 'Database File can not be connected' )
else
msginfo( iif( miscsql( oDB, 'pragma key = ' + c2sql( cKey ) ), 'Encryption Key is set', 'Encryption key can not be set' ) )
aTable := sql( oDB, 'select name, city from master' )
if len( aTable ) > 0
msginfo( 'Name:' + aTable[ 1, 1 ] + ' City:' + aTable[ 1, 2 ] )
endif
endif
else
oDB := connect2db( 'sample.sqlite', .t. )
if oDB == Nil
msgstop( 'Database File can not be connected' )
else
msginfo( iif( miscsql( oDB, 'pragma key = ' + c2sql( cKey ) ), 'Encryption Key is set', 'Encryption key can not be set!' ) )
msginfo( iif( miscsql( oDB, 'create table master (name, city)' ), 'Master table is created successfully!', 'Table can not be created!' ) )
msginfo( iif( miscsql( oDB, 'insert into master ( name, city ) values ( ' + c2sql( 'Name1' ) + ', ' + c2sql( 'City1' ) + ' )' ), 'Sample Data updated', 'sample data can not be updated!' ) )
endif
endif
Return nil
Code: Select all
inc=yes
head=native
libs=hmgsqlite
libs=sqlcipher
libs=eay32
I have enclosed herewith sqlite3.c, sqlite3.h, libsqlcipher.a. Kindly test with your applications and give your feedback.
Enjoy HMGing!