Installing SQLCipher in Ubuntu

2,127 views
Skip to first unread message

cris

unread,
Jun 14, 2011, 1:21:11 PM6/14/11
to SQLCipher Users
Hi.

Followed the instructions to install SQLCipher on my computer.( I use
Ubuntu 9.10)

1. Compiling with dynamic linking:

./configure --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC"
LDFLAGS="-lcrypto"

2. make

3. make install DESTDIR=/path_my_user/desktop/crypto

4. cd /path_my_user/desktop/crypto/usr/local/bin

5. cris:~ /path_my_user/desktop/crypto/usr/local/bin$ ./sqlite3
bdatos.db

6. sqlite> PRAGMA key='123';

7. sqlite> CREATE TABLE data(id text);

8. sqlite>.quit

9. cris:~ /path_my_user/desktop/crypto/usr/local/bin$ hexdump -C
bdatos.db

00000000 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 |SQLite
format 3.|
00000010 04 00 01 01 00 40 20 20 00 00 00 01 00 00 00 00
|.....@ ........|
00000020 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 01
|................|
00000030 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00
|................|
00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|................|
*
00000060 00 00 00 00 0d 00 00 00 01 03 d9 00 03 d9 00 00
|................|
00000070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|................|
*
000003d0 00 00 00 00 00 00 00 00 00 25 01 06 17 0f 0f 01 |.........
%......|
000003e0 3b 74 61 62 6c 65 64 64 02 43 52 45 41 54 45 20
|;tabledd.CREATE |
000003f0 54 41 42 4c 45 20 64 28 69 64 20 74 65 78 74 29 |TABLE
data(id text)|
00000400 0d 00 00 00 00 04 00 00 00 00 00 00 00 00 00 00
|................|
00000410 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|................|
*
00000800

Is it right what I'm doing?

Thanks in advance for any help.

Best Regards

Cris

cris

unread,
Jun 14, 2011, 5:06:34 PM6/14/11
to SQLCipher Users
Hi.

In ubuntu 9.10, install package tcl8.5-dev.

cris

Stephen Lombardo

unread,
Jun 14, 2011, 5:33:32 PM6/14/11
to sqlc...@googlegroups.com
Chrs,

You are probably running the sqlite3 command but using the stock sqlite3 lib that ships with ubuntu. You would need to place the location of the libraries into LD_LIBRARY_PATH so they can be located by the sqlite shell. Try running this before you run sqlite3

$ export LD_LIBRARY_PATH=/path_my_user/desktop/crypto/usr/local/lib:$LD_LIBRARY_PATH

Cheers,
Stephen

craf

unread,
Jun 14, 2011, 7:23:46 PM6/14/11
to sqlc...@googlegroups.com
>Chrs,


>You are probably running the sqlite3 command but using the stock
>sqlite3 lib that ships with ubuntu. You would need to place the
>location of the libraries into LD_LIBRARY_PATH so they can be located
>by the sqlite shell. Try running this before you run sqlite3


>$ export
>LD_LIBRARY_PATH=/path_my_user/desktop/crypto/usr/local/lib:>$LD_LIBRARY_PATH


>Cheers,
>Stephen


Hi Stephen.

Thank you very much for answering!.

I managed to configure and compile and create an encrypted database.

Now, I'm trying to access it through Python, using the following code:

CODE PYTHON:--------------------------------------------------------

#!/usr/bin/python
# -*- encoding:utf-8 -*-


import sqlite3

conn=sqlite3.connect('bdata.db')

c = conn.cursor()

c.execute("PRAGMA key='123'")

c.execute('select * from data')

for row in c:
print row[0], row[1]

c.close()
---------------------------------------------------------

If the database is not encrypted, I can read the data, but if it is, no

You can connect using Python?

NOTE:*****************************************************************

I tried to compile statically SQLCipher, with the following statement
from the website:

./configure --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC"
LDFLAGS="/usr/lib/libcrypto.a"


But it throws me the following error:

*** Warning: Linking the shared library libsqlite3.la against the
*** static library /usr/lib/libcrypto.a is not portable!
....
....
.... bla,bla...

./.libs/libsqlite3.so: undefined reference to `dlsym'
./.libs/libsqlite3.so: undefined reference to `dlerror'
./.libs/libsqlite3.so: undefined reference to `dlopen'
./.libs/libsqlite3.so: undefined reference to `dlclose'
collect2: ld returned 1 exit status
make: *** [sqlite3] Error 1

why?.

************************************************************************

thank you in advance.

Best Regards.

Cris.

cris

unread,
Jun 14, 2011, 8:18:42 PM6/14/11
to SQLCipher Users
Hi. Stephen.

Works!

SQLCipher is a great product. Thank you very much for sharing!.

Best Regards.

Cris

Stephen Lombardo

unread,
Jun 14, 2011, 11:11:52 PM6/14/11
to sqlc...@googlegroups.com
Hi Cris,

The same trick should work for python. Just set LD_LIBRARY_PATH before executing your python program and it will cause the python sqlite bindings to use the sqlcipher-enabled library. Here is some more information.


Cheers,
Stephen

craf

unread,
Jun 15, 2011, 12:08:08 PM6/15/11
to sqlc...@googlegroups.com
>Hi Cris,

>The same trick should work for python. Just set LD_LIBRARY_PATH before
>executing your python program and it will cause the python sqlite
>bindings to use the sqlcipher-enabled library. Here is some more
>information.


>http://groups.google.com/group/sqlcipher/browse_thread/thread/3928aecc7937f272?pli=1


>Cheers,
>Stephen

Hi. Stephen.

Thank you very much for the information!. Now works properly.

Cuestion:-

Is it possible to compile statically SQLCipher in Ubuntu? or create
binary SQLCipher in Ubuntu?.

I've tried:

COMMAND 1 :====================================================

./configure --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC"
LDFLAGS="-lcrypto"

ERROR WHEN RUNNING MAKE:

*** Warning: Linking the shared library libsqlite3.la against the
*** static library /usr/lib/libcrypto.a is not portable!
....
....
.... bla,bla...

./.libs/libsqlite3.so: undefined reference to `dlsym'
./.libs/libsqlite3.so: undefined reference to `dlerror'
./.libs/libsqlite3.so: undefined reference to `dlopen'
./.libs/libsqlite3.so: undefined reference to `dlclose'
collect2: ld returned 1 exit status
make: *** [sqlite3] Error 1

COMMAND 2 :=============================================================

./configure --prefix=/home/cris/desktop/sqlcipher-binaries --disable-tcl
--enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC" LDFLAGS="-l crypto"

ERROR WHEN RUNNING MAKE:
....
....
libtool: link: gcc -shared .libs/sqlite3.o -l -lpthread
-Wl,-soname -Wl,libsqlite3.so.0 -o .libs/libsqlite3.so.0.8.6
/usr/bin/ld: cannot find -l-lpthread


collect2: ld returned 1 exit status

make: *** [libsqlite3.la] Error 1

SEARCH lpthread :

cris:~ locate libpthread

/lib/libpthread.so.0
/lib/tls/i686/cmov/libpthread.so.0
/usr/lib/libpthread.a

How I can give the path in the configuration?

Best Regards.

Cris

Stephen Lombardo

unread,
Jul 7, 2011, 1:10:41 AM7/7/11
to sqlc...@googlegroups.com
Hi Cris,

If you just want to compile the static lib you could try the --disable-shared option, i.e.

$ ./configure --disable-shared --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC" LDFLAGS="-lcrypto"

Cheers,
Stephen
Message has been deleted

Nick Parker

unread,
Mar 13, 2015, 9:12:03 AM3/13/15
to sqlc...@googlegroups.com

On 13 Mar 2015, at 7:21, AmirHossein NickAein wrote:

hi
i have a problem in configuring:
in dynamic linking, i receive this error:
checking whether the C compiler works... no
in static linking, this error:
configure: error: Library crypto not found. Install openssl!"
for static method, i built last version of openssl

what's wrong?

The error message is showing you that you are missing the OpenSSL dependency on your machine. On Ubuntu you need to install the following:

apt-get install libssl-dev

Nick Parker

Reply all
Reply to author
Forward
0 new messages