QtCipherSqlitePlugin icon indicating copy to clipboard operation
QtCipherSqlitePlugin copied to clipboard

QtCipherSqlitePlugin in QT using Kit for Android

Open jasmineseth opened this issue 7 years ago • 18 comments

I have imported QtCipherSqlitePlugin in QT using Android kit. But getting lot of errors after build. M i missing any step. Please let me know how to do the same for android?

jasmineseth avatar Oct 31 '18 05:10 jasmineseth

I encounter errors too while using Qt 5.12.0 and Android ndk clang compiler. From the error message, I got it is because the variables u64 B0, B1, ... in shatree.c are conflicted with the macros B0, B1, ... in android-ndk-r18b/sysroot/usr/include/asm-generic/termbits.h.

scienceasdf avatar Dec 22 '18 14:12 scienceasdf

I've tried to rename the B0, B1, B2, ... to m_B0, m_B1, m_B2, ... like this:

static void KeccakF1600Step(SHA3Context *p){
  int i;
  u64 m_B0, m_B1, m_B2, m_B3, m_B4;
  u64 C0, C1, C2, C3, C4;
  u64 D0, D1, D2, D3, D4;
  static const u64 RC[] = {
    0x0000000000000001ULL,  0x0000000000008082ULL,
    0x800000000000808aULL,  0x8000000080008000ULL,
    0x000000000000808bULL,  0x0000000080000001ULL,
    0x8000000080008081ULL,  0x8000000000008009ULL,
    0x000000000000008aULL,  0x0000000000000088ULL,
    0x0000000080008009ULL,  0x000000008000000aULL,
    0x000000008000808bULL,  0x800000000000008bULL,
    0x8000000000008089ULL,  0x8000000000008003ULL,
    0x8000000000008002ULL,  0x8000000000000080ULL,
    0x000000000000800aULL,  0x800000008000000aULL,
    0x8000000080008081ULL,  0x8000000000008080ULL,
    0x0000000080000001ULL,  0x8000000080008008ULL
  };
# define A00 (p->u.s[0])
# define A01 (p->u.s[1])
# define A02 (p->u.s[2])
# define A03 (p->u.s[3])
# define A04 (p->u.s[4])
# define A10 (p->u.s[5])
# define A11 (p->u.s[6])
# define A12 (p->u.s[7])
# define A13 (p->u.s[8])
# define A14 (p->u.s[9])
# define A20 (p->u.s[10])
# define A21 (p->u.s[11])
# define A22 (p->u.s[12])
# define A23 (p->u.s[13])
# define A24 (p->u.s[14])
# define A30 (p->u.s[15])
# define A31 (p->u.s[16])
# define A32 (p->u.s[17])
# define A33 (p->u.s[18])
# define A34 (p->u.s[19])
# define A40 (p->u.s[20])
# define A41 (p->u.s[21])
# define A42 (p->u.s[22])
# define A43 (p->u.s[23])
# define A44 (p->u.s[24])
# define ROL64(a,x) ((a<<x)|(a>>(64-x)))

  for(i=0; i<24; i+=4){
    C0 = A00^A10^A20^A30^A40;
    C1 = A01^A11^A21^A31^A41;
    C2 = A02^A12^A22^A32^A42;
    C3 = A03^A13^A23^A33^A43;
    C4 = A04^A14^A24^A34^A44;
    D0 = C4^ROL64(C1, 1);
    D1 = C0^ROL64(C2, 1);
    D2 = C1^ROL64(C3, 1);
    D3 = C2^ROL64(C4, 1);
    D4 = C3^ROL64(C0, 1);

    m_B0 = (A00^D0);
    m_B1 = ROL64((A11^D1), 44);
    m_B2 = ROL64((A22^D2), 43);
    m_B3 = ROL64((A33^D3), 21);
    m_B4 = ROL64((A44^D4), 14);
    A00 =   m_B0 ^((~m_B1)&  m_B2 );
    A00 ^= RC[i];
    A11 =   m_B1 ^((~m_B2)&  m_B3 );
    A22 =   m_B2 ^((~m_B3)&  m_B4 );
    A33 =   m_B3 ^((~m_B4)&  m_B0 );
    A44 =   m_B4 ^((~m_B0)&  m_B1 );

    m_B2 = ROL64((A20^D0), 3);
    m_B3 = ROL64((A31^D1), 45);
    m_B4 = ROL64((A42^D2), 61);
    m_B0 = ROL64((A03^D3), 28);
    m_B1 = ROL64((A14^D4), 20);
    A20 =   m_B0 ^((~m_B1)&  m_B2 );
    A31 =   m_B1 ^((~m_B2)&  m_B3 );
    A42 =   m_B2 ^((~m_B3)&  m_B4 );
    A03 =   m_B3 ^((~m_B4)&  m_B0 );
    A14 =   m_B4 ^((~m_B0)&  m_B1 );

    m_B4 = ROL64((A40^D0), 18);
    m_B0 = ROL64((A01^D1), 1);
    m_B1 = ROL64((A12^D2), 6);
    m_B2 = ROL64((A23^D3), 25);
    m_B3 = ROL64((A34^D4), 8);
    A40 =   m_B0 ^((~m_B1)&  m_B2 );
    A01 =   m_B1 ^((~m_B2)&  m_B3 );
    A12 =   m_B2 ^((~m_B3)&  m_B4 );
    A23 =   m_B3 ^((~m_B4)&  m_B0 );
    A34 =   m_B4 ^((~m_B0)&  m_B1 );

    m_B1 = ROL64((A10^D0), 36);
    m_B2 = ROL64((A21^D1), 10);
    m_B3 = ROL64((A32^D2), 15);
    m_B4 = ROL64((A43^D3), 56);
    m_B0 = ROL64((A04^D4), 27);
    A10 =   m_B0 ^((~m_B1)&  m_B2 );
    A21 =   m_B1 ^((~m_B2)&  m_B3 );
    A32 =   m_B2 ^((~m_B3)&  m_B4 );
    A43 =   m_B3 ^((~m_B4)&  m_B0 );
    A04 =   m_B4 ^((~m_B0)&  m_B1 );

    m_B3 = ROL64((A30^D0), 41);
    m_B4 = ROL64((A41^D1), 2);
    m_B0 = ROL64((A02^D2), 62);
    m_B1 = ROL64((A13^D3), 55);
    m_B2 = ROL64((A24^D4), 39);
    A30 =   m_B0 ^((~m_B1)&  m_B2 );
    A41 =   m_B1 ^((~m_B2)&  m_B3 );
    A02 =   m_B2 ^((~m_B3)&  m_B4 );
    A13 =   m_B3 ^((~m_B4)&  m_B0 );
    A24 =   m_B4 ^((~m_B0)&  m_B1 );

    C0 = A00^A20^A40^A10^A30;
    C1 = A11^A31^A01^A21^A41;
    C2 = A22^A42^A12^A32^A02;
    C3 = A33^A03^A23^A43^A13;
    C4 = A44^A14^A34^A04^A24;
    D0 = C4^ROL64(C1, 1);
    D1 = C0^ROL64(C2, 1);
    D2 = C1^ROL64(C3, 1);
    D3 = C2^ROL64(C4, 1);
    D4 = C3^ROL64(C0, 1);

    m_B0 = (A00^D0);
    m_B1 = ROL64((A31^D1), 44);
    m_B2 = ROL64((A12^D2), 43);
    m_B3 = ROL64((A43^D3), 21);
    m_B4 = ROL64((A24^D4), 14);
    A00 =   m_B0 ^((~m_B1)&  m_B2 );
    A00 ^= RC[i+1];
    A31 =   m_B1 ^((~m_B2)&  m_B3 );
    A12 =   m_B2 ^((~m_B3)&  m_B4 );
    A43 =   m_B3 ^((~m_B4)&  m_B0 );
    A24 =   m_B4 ^((~m_B0)&  m_B1 );

    m_B2 = ROL64((A40^D0), 3);
    m_B3 = ROL64((A21^D1), 45);
    m_B4 = ROL64((A02^D2), 61);
    m_B0 = ROL64((A33^D3), 28);
    m_B1 = ROL64((A14^D4), 20);
    A40 =   m_B0 ^((~m_B1)&  m_B2 );
    A21 =   m_B1 ^((~m_B2)&  m_B3 );
    A02 =   m_B2 ^((~m_B3)&  m_B4 );
    A33 =   m_B3 ^((~m_B4)&  m_B0 );
    A14 =   m_B4 ^((~m_B0)&  m_B1 );

    m_B4 = ROL64((A30^D0), 18);
    m_B0 = ROL64((A11^D1), 1);
    m_B1 = ROL64((A42^D2), 6);
    m_B2 = ROL64((A23^D3), 25);
    m_B3 = ROL64((A04^D4), 8);
    A30 =   m_B0 ^((~m_B1)&  m_B2 );
    A11 =   m_B1 ^((~m_B2)&  m_B3 );
    A42 =   m_B2 ^((~m_B3)&  m_B4 );
    A23 =   m_B3 ^((~m_B4)&  m_B0 );
    A04 =   m_B4 ^((~m_B0)&  m_B1 );

    m_B1 = ROL64((A20^D0), 36);
    m_B2 = ROL64((A01^D1), 10);
    m_B3 = ROL64((A32^D2), 15);
    m_B4 = ROL64((A13^D3), 56);
    m_B0 = ROL64((A44^D4), 27);
    A20 =   m_B0 ^((~m_B1)&  m_B2 );
    A01 =   m_B1 ^((~m_B2)&  m_B3 );
    A32 =   m_B2 ^((~m_B3)&  m_B4 );
    A13 =   m_B3 ^((~m_B4)&  m_B0 );
    A44 =   m_B4 ^((~m_B0)&  m_B1 );

    m_B3 = ROL64((A10^D0), 41);
    m_B4 = ROL64((A41^D1), 2);
    m_B0 = ROL64((A22^D2), 62);
    m_B1 = ROL64((A03^D3), 55);
    m_B2 = ROL64((A34^D4), 39);
    A10 =   m_B0 ^((~m_B1)&  m_B2 );
    A41 =   m_B1 ^((~m_B2)&  m_B3 );
    A22 =   m_B2 ^((~m_B3)&  m_B4 );
    A03 =   m_B3 ^((~m_B4)&  m_B0 );
    A34 =   m_B4 ^((~m_B0)&  m_B1 );

    C0 = A00^A40^A30^A20^A10;
    C1 = A31^A21^A11^A01^A41;
    C2 = A12^A02^A42^A32^A22;
    C3 = A43^A33^A23^A13^A03;
    C4 = A24^A14^A04^A44^A34;
    D0 = C4^ROL64(C1, 1);
    D1 = C0^ROL64(C2, 1);
    D2 = C1^ROL64(C3, 1);
    D3 = C2^ROL64(C4, 1);
    D4 = C3^ROL64(C0, 1);

    m_B0 = (A00^D0);
    m_B1 = ROL64((A21^D1), 44);
    m_B2 = ROL64((A42^D2), 43);
    m_B3 = ROL64((A13^D3), 21);
    m_B4 = ROL64((A34^D4), 14);
    A00 =   m_B0 ^((~m_B1)&  m_B2 );
    A00 ^= RC[i+2];
    A21 =   m_B1 ^((~m_B2)&  m_B3 );
    A42 =   m_B2 ^((~m_B3)&  m_B4 );
    A13 =   m_B3 ^((~m_B4)&  m_B0 );
    A34 =   m_B4 ^((~m_B0)&  m_B1 );

    m_B2 = ROL64((A30^D0), 3);
    m_B3 = ROL64((A01^D1), 45);
    m_B4 = ROL64((A22^D2), 61);
    m_B0 = ROL64((A43^D3), 28);
    m_B1 = ROL64((A14^D4), 20);
    A30 =   m_B0 ^((~m_B1)&  m_B2 );
    A01 =   m_B1 ^((~m_B2)&  m_B3 );
    A22 =   m_B2 ^((~m_B3)&  m_B4 );
    A43 =   m_B3 ^((~m_B4)&  m_B0 );
    A14 =   m_B4 ^((~m_B0)&  m_B1 );

    m_B4 = ROL64((A10^D0), 18);
    m_B0 = ROL64((A31^D1), 1);
    m_B1 = ROL64((A02^D2), 6);
    m_B2 = ROL64((A23^D3), 25);
    m_B3 = ROL64((A44^D4), 8);
    A10 =   m_B0 ^((~m_B1)&  m_B2 );
    A31 =   m_B1 ^((~m_B2)&  m_B3 );
    A02 =   m_B2 ^((~m_B3)&  m_B4 );
    A23 =   m_B3 ^((~m_B4)&  m_B0 );
    A44 =   m_B4 ^((~m_B0)&  m_B1 );

    m_B1 = ROL64((A40^D0), 36);
    m_B2 = ROL64((A11^D1), 10);
    m_B3 = ROL64((A32^D2), 15);
    m_B4 = ROL64((A03^D3), 56);
    m_B0 = ROL64((A24^D4), 27);
    A40 =   m_B0 ^((~m_B1)&  m_B2 );
    A11 =   m_B1 ^((~m_B2)&  m_B3 );
    A32 =   m_B2 ^((~m_B3)&  m_B4 );
    A03 =   m_B3 ^((~m_B4)&  m_B0 );
    A24 =   m_B4 ^((~m_B0)&  m_B1 );

    m_B3 = ROL64((A20^D0), 41);
    m_B4 = ROL64((A41^D1), 2);
    m_B0 = ROL64((A12^D2), 62);
    m_B1 = ROL64((A33^D3), 55);
    m_B2 = ROL64((A04^D4), 39);
    A20 =   m_B0 ^((~m_B1)&  m_B2 );
    A41 =   m_B1 ^((~m_B2)&  m_B3 );
    A12 =   m_B2 ^((~m_B3)&  m_B4 );
    A33 =   m_B3 ^((~m_B4)&  m_B0 );
    A04 =   m_B4 ^((~m_B0)&  m_B1 );

    C0 = A00^A30^A10^A40^A20;
    C1 = A21^A01^A31^A11^A41;
    C2 = A42^A22^A02^A32^A12;
    C3 = A13^A43^A23^A03^A33;
    C4 = A34^A14^A44^A24^A04;
    D0 = C4^ROL64(C1, 1);
    D1 = C0^ROL64(C2, 1);
    D2 = C1^ROL64(C3, 1);
    D3 = C2^ROL64(C4, 1);
    D4 = C3^ROL64(C0, 1);

    m_B0 = (A00^D0);
    m_B1 = ROL64((A01^D1), 44);
    m_B2 = ROL64((A02^D2), 43);
    m_B3 = ROL64((A03^D3), 21);
    m_B4 = ROL64((A04^D4), 14);
    A00 =   m_B0 ^((~m_B1)&  m_B2 );
    A00 ^= RC[i+3];
    A01 =   m_B1 ^((~m_B2)&  m_B3 );
    A02 =   m_B2 ^((~m_B3)&  m_B4 );
    A03 =   m_B3 ^((~m_B4)&  m_B0 );
    A04 =   m_B4 ^((~m_B0)&  m_B1 );

    m_B2 = ROL64((A10^D0), 3);
    m_B3 = ROL64((A11^D1), 45);
    m_B4 = ROL64((A12^D2), 61);
    m_B0 = ROL64((A13^D3), 28);
    m_B1 = ROL64((A14^D4), 20);
    A10 =   m_B0 ^((~m_B1)&  m_B2 );
    A11 =   m_B1 ^((~m_B2)&  m_B3 );
    A12 =   m_B2 ^((~m_B3)&  m_B4 );
    A13 =   m_B3 ^((~m_B4)&  m_B0 );
    A14 =   m_B4 ^((~m_B0)&  m_B1 );

    m_B4 = ROL64((A20^D0), 18);
    m_B0 = ROL64((A21^D1), 1);
    m_B1 = ROL64((A22^D2), 6);
    m_B2 = ROL64((A23^D3), 25);
    m_B3 = ROL64((A24^D4), 8);
    A20 =   m_B0 ^((~m_B1)&  m_B2 );
    A21 =   m_B1 ^((~m_B2)&  m_B3 );
    A22 =   m_B2 ^((~m_B3)&  m_B4 );
    A23 =   m_B3 ^((~m_B4)&  m_B0 );
    A24 =   m_B4 ^((~m_B0)&  m_B1 );

    m_B1 = ROL64((A30^D0), 36);
    m_B2 = ROL64((A31^D1), 10);
    m_B3 = ROL64((A32^D2), 15);
    m_B4 = ROL64((A33^D3), 56);
    m_B0 = ROL64((A34^D4), 27);
    A30 =   m_B0 ^((~m_B1)&  m_B2 );
    A31 =   m_B1 ^((~m_B2)&  m_B3 );
    A32 =   m_B2 ^((~m_B3)&  m_B4 );
    A33 =   m_B3 ^((~m_B4)&  m_B0 );
    A34 =   m_B4 ^((~m_B0)&  m_B1 );

    m_B3 = ROL64((A40^D0), 41);
    m_B4 = ROL64((A41^D1), 2);
    m_B0 = ROL64((A42^D2), 62);
    m_B1 = ROL64((A43^D3), 55);
    m_B2 = ROL64((A44^D4), 39);
    A40 =   m_B0 ^((~m_B1)&  m_B2 );
    A41 =   m_B1 ^((~m_B2)&  m_B3 );
    A42 =   m_B2 ^((~m_B3)&  m_B4 );
    A43 =   m_B3 ^((~m_B4)&  m_B0 );
    A44 =   m_B4 ^((~m_B0)&  m_B1 );
  }
}

And then all this project can be built with NDK r18b clang toolchain.

scienceasdf avatar Dec 25 '18 09:12 scienceasdf

I had fix compile B0 error, but can't generate so file, how to fix it? NDK r18b? I just found NDK r16b?

liaoxuewei avatar Feb 14 '19 14:02 liaoxuewei

they said just build this project with app template, and open the generated apk file with archive softwares, then take the .so file inside

DisableAsync avatar Feb 15 '19 01:02 DisableAsync

I could not generate any file, because there ware some errors in generating the file.

E:\Opensource\QtCipherSqlitePlugin\build-sqlitecipher-Android_for_armeabi_v7a_GCC_4_9_Qt_5_10_1_for_Android_armv7-Release.obj\regexp.obj: -1: error: file not recognized: File format not recognized collect2.exe: -1: error: error: ld returned 1 exit status

liaoxuewei avatar Feb 15 '19 01:02 liaoxuewei

have you tried to use new version of Qt? i installed all new version of everything just now and successfully built android library (errors actually generated, but they were about copying libs to qt installation dir. the lib was still properly made) and tested it in an x86 emulator, everything worked just fine!

DisableAsync avatar Feb 15 '19 08:02 DisableAsync

It worked fine now, there are some thing wrong. But i don't why, thinks!

liaoxuewei avatar Feb 27 '19 13:02 liaoxuewei

It worked fine now, there are some thing wrong. But i don't why, thinks!

I had the same problem. How did you solve it?

qt5.13 + mingw + android (ndkr19c)

zj511025 avatar Aug 19 '19 05:08 zj511025

have you tried to use new version of Qt? i installed all new version of everything just now and successfully built android library (errors actually generated, but they were about copying libs to qt installation dir. the lib was still properly made) and tested it in an x86 emulator, everything worked just fine!

I had the same problem. How did you solve it?

win+qt5.13 + mingw + android (ndkr19c)

zj511025 avatar Aug 20 '19 01:08 zj511025

have you tried to use new version of Qt? i installed all new version of everything just now and successfully built android library (errors actually generated, but they were about copying libs to qt installation dir. the lib was still properly made) and tested it in an x86 emulator, everything worked just fine!

I had the same problem. How did you solve it?

win+qt5.13 + mingw + android (ndkr19c)

to be specific, which problem you meant?

DisableAsync avatar Aug 20 '19 11:08 DisableAsync

have you tried to use new version of Qt? i installed all new version of everything just now and successfully built android library (errors actually generated, but they were about copying libs to qt installation dir. the lib was still properly made) and tested it in an x86 emulator, everything worked just fine!

I had the same problem. How did you solve it? win+qt5.13 + mingw + android (ndkr19c)

to be specific, which problem you meant?

我的意思是: 我和scienceasdf遇到了相同的问题。我在windows平台下,使用qt5.13,使用mingw编译Android_for_armeabi_v7a版本(ndk r19c),在下面的函数中报错: static void KeccakF1600Step(SHA3Context *p) 1、u64 未定义 2、我打开上面的u64定义之后,报B0重复定义

我想请问一下,您们是如何解决这个问题的?

zj511025 avatar Aug 21 '19 01:08 zj511025

右鍵點擊 B0,點選重構,隨便起個名字

參考

DisableAsync avatar Aug 21 '19 04:08 DisableAsync

右鍵點擊 B0,點選重構,隨便起個名字

參考

我是这么修改的。编译后报拷贝文件错误。我再到编译输出目录下看,实际上没有生成任何文件。不知为什么?

zj511025 avatar Aug 22 '19 00:08 zj511025

我試着重複這個問題,但是這次解決了u64和B0的問題後建置通過,沒有出現錯誤...

你可以試着在建置目錄下搜尋libsqlitecipher.so

DisableAsync avatar Aug 22 '19 04:08 DisableAsync

我試着重複這個問題,但是這次解決了u64和B0的問題後建置通過,沒有出現錯誤...

你可以試着在建置目錄下搜尋libsqlitecipher.so

我搜了整个目录,没有找到libsqlitecipher.so文件。 您发现问题了吗?

zj511025 avatar Sep 06 '19 00:09 zj511025

抱歉哈,真的不了解情況。

DisableAsync avatar Sep 06 '19 03:09 DisableAsync

抱歉哈,真的不了解情況。

这个插件,对qt和Android的版本有要求吗?

zj511025 avatar Sep 06 '19 07:09 zj511025

不知道哦。 我這邊用的東西都是最新版本。 主機作業系統的話是Pop!_OS 19.04。

DisableAsync avatar Sep 06 '19 11:09 DisableAsync