Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Building Qt SQLCipher driver
QtWS25 Last Chance

Building Qt SQLCipher driver

Scheduled Pinned Locked Moved Solved General and Desktop
15 Posts 4 Posters 4.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AndersDK
    wrote on last edited by
    #1

    Hello

    Im trying to build the following https://github.com/sijk/qt5-sqlcipher/blob/master/README.md sqlcipher drivers for Qt with cmake.

    So far I've gotten cmake to run, and create the build files. But when I try to build I get the following error:

    "C:\QtSQLCipher\build\ALL_BUILD.vcxproj" (default target) (1) ->
    "C:\QtSQLCipher\build\qsqlcipher.vcxproj" (default target) (3) ->
    (ClCompile target) ->
      c:\qtsqlcipher\build\qsqlcipher_autogen\R265ZHLO6Z/moc_qsql_sqlite_p_Debug.cpp(63): error C2491: 'QSQLiteDriver::staticMetaObject': definition of dllimport static data m
    ember not allowed [C:\QtSQLCipher\build\qsqlcipher.vcxproj]
    

    I've tried google but I can't find out how to resolve this. Hope someone can help me.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      What exactly did you do ?
      Which version of Qt are you using ?
      Which version of cmake ?
      For what exact version of Visual Studio ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • A Offline
        A Offline
        AndersDK
        wrote on last edited by
        #3

        Im using Qt 5.11.1

        I ran the following cmake command

        cmake C:\QtSQLCipher -BC:\QtSQLCipher\build -G"Visual Studio 14 2015 Win64" -DCMAKE_PREFIX_PATH=C:\Qt\5.11.1\msvc2015_64\lib\cmake\Qt5Sql
        

        Getting the following response

        -- Selecting Windows SDK version 10.0.14393.0 to target Windows 10.0.17134.
        -- The C compiler identification is MSVC 19.0.24215.1
        -- The CXX compiler identification is MSVC 19.0.24215.1
        -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe
        -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe -- works
        -- Detecting C compiler ABI info
        -- Detecting C compiler ABI info - done
        -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe
        -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe -- works
        -- Detecting CXX compiler ABI info
        -- Detecting CXX compiler ABI info - done
        -- Detecting CXX compile features
        -- Detecting CXX compile features - done
        -- Found PkgConfig: C:/QtSQLCipher/pkg-config.exe (found version "0.28")
        -- Checking for module 'sqlcipher'
        --   Found sqlcipher, version @PACKAGE_VERSION@
        -- Configuring done
        -- Generating done
        -- Build files have been written to: C:/QtSQLCipher/build
        

        Then I ran

        make --build C:\QtSQLCipher\build
        
        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Why not build it using Qt Creator ? That would simplify the setup process and ensure the build environment is correctly setup.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1
          • A Offline
            A Offline
            AndersDK
            wrote on last edited by
            #5

            Sounds great. But I don't know how to do that.

            Can I also build the SQLcipher lib it uses, which I build with nmake?

            1 Reply Last reply
            0
            • A Offline
              A Offline
              AndersDK
              wrote on last edited by
              #6

              Got it imported in Qt, but get the same error when building:

              C:\build-QtSQLCipher-Desktop_Qt_5_11_1_MSVC2015_64bit-Default\qsqlcipher_autogen\R265ZHLO6Z\moc_qsql_sqlite_p.cpp:80: error: C2491: 'QSQLiteDriver::staticMetaObject': definition of dllimport static data member not allowed

              aha_1980A 1 Reply Last reply
              0
              • A AndersDK

                Got it imported in Qt, but get the same error when building:

                C:\build-QtSQLCipher-Desktop_Qt_5_11_1_MSVC2015_64bit-Default\qsqlcipher_autogen\R265ZHLO6Z\moc_qsql_sqlite_p.cpp:80: error: C2491: 'QSQLiteDriver::staticMetaObject': definition of dllimport static data member not allowed

                aha_1980A Offline
                aha_1980A Offline
                aha_1980
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @AndersDK it seems the author has not used Windows/MSVC so far.

                Maybe its easiest to contact him to solve the problem?

                Qt has to stay free or it will die.

                1 Reply Last reply
                1
                • A Offline
                  A Offline
                  AndersDK
                  wrote on last edited by
                  #8

                  It refers to the following lines of a moc file

                  QT_INIT_METAOBJECT const QMetaObject QSQLiteDriver::staticMetaObject = {
                      { &QSqlDriver::staticMetaObject, qt_meta_stringdata_QSQLiteDriver.data,
                        qt_meta_data_QSQLiteDriver,  qt_static_metacall, nullptr, nullptr}
                  };
                  
                  mrjjM 1 Reply Last reply
                  0
                  • A AndersDK

                    It refers to the following lines of a moc file

                    QT_INIT_METAOBJECT const QMetaObject QSQLiteDriver::staticMetaObject = {
                        { &QSqlDriver::staticMetaObject, qt_meta_stringdata_QSQLiteDriver.data,
                          qt_meta_data_QSQLiteDriver,  qt_static_metacall, nullptr, nullptr}
                    };
                    
                    mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by mrjj
                    #9

                    @AndersDK
                    Hej
                    That error seems to come from
                    __declspec(dllimport)

                    https://stackoverflow.com/questions/3491990/c-definition-of-dllimport-static-data-member

                    But the odd part is that its in a moc file which is generated so
                    i was wondering how QSQLiteDriver is flagged (__declspec(dllexport) )
                    or if it need to be flagged for visual studio to be happy.
                    Since its only tested on mac/linux , it might need some extra
                    __declspec exports /handling.

                    1 Reply Last reply
                    1
                    • A Offline
                      A Offline
                      AndersDK
                      wrote on last edited by
                      #10

                      You might be right. But I don't know how to resolve it.

                      Is it possible to find already build drivers i can use with qt.

                      Maybe I should explain what I really need to solve.

                      I have a program that uses a local database file, created with sqlitestudio. I need to change the database file to sqlcipher in the release to protect the data, because my research tell me that I can't protect a sqlite database. So in reality what I need is a protected database that I can easily access through qt. The only specification is it need to be a local file, and a free or cheap solution. Don't need to be sqlite.

                      Are there an easier solution than trying to create a sqlcipher driver?

                      mrjjM 1 Reply Last reply
                      0
                      • A AndersDK

                        You might be right. But I don't know how to resolve it.

                        Is it possible to find already build drivers i can use with qt.

                        Maybe I should explain what I really need to solve.

                        I have a program that uses a local database file, created with sqlitestudio. I need to change the database file to sqlcipher in the release to protect the data, because my research tell me that I can't protect a sqlite database. So in reality what I need is a protected database that I can easily access through qt. The only specification is it need to be a local file, and a free or cheap solution. Don't need to be sqlite.

                        Are there an easier solution than trying to create a sqlcipher driver?

                        mrjjM Offline
                        mrjjM Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        @AndersDK
                        Hi
                        Me neither but others users here have brilliant visual studio knowledge
                        so all hope is not lost yet. I think it just need a bit more tweak to compile
                        on windows.

                        if a database is not really required, a local file with
                        https://github.com/bricke/Qt-AES
                        could do the trick.

                        Most users here are in other timezones than DK so give it a day or two and
                        someone might know the answer.

                        1 Reply Last reply
                        1
                        • A Offline
                          A Offline
                          AndersDK
                          wrote on last edited by
                          #12

                          Thanks for the suggestion. I think I need the database to keep it organized, and easily maintainable.

                          I will wait and hope someone can guide me to the solution.

                          mrjjM 1 Reply Last reply
                          1
                          • A AndersDK

                            Thanks for the suggestion. I think I need the database to keep it organized, and easily maintainable.

                            I will wait and hope someone can guide me to the solution.

                            mrjjM Offline
                            mrjjM Offline
                            mrjj
                            Lifetime Qt Champion
                            wrote on last edited by
                            #13

                            @AndersDK
                            Yeah, if you have multiple tables and/or relations and use
                            Queries to get data, a flat file will not work well.

                            1 Reply Last reply
                            0
                            • A Offline
                              A Offline
                              AndersDK
                              wrote on last edited by
                              #14

                              Hello

                              I couldn't get it to work. However, I found out that I could use WxSQLite3 in SQLitestudio. Googling I found a driver plugin script in the following post:

                              https://forum.qt.io/topic/79431/c-sqlite3-encrypted-db/5

                              This pluging was easy to compile directly through Qt, and no need to compile other files to make it work. The output is dlls which should just be put in the Qt sqldriver folder. This work with no problem, and I now got an encrypted database.

                              aha_1980A 1 Reply Last reply
                              3
                              • A AndersDK

                                Hello

                                I couldn't get it to work. However, I found out that I could use WxSQLite3 in SQLitestudio. Googling I found a driver plugin script in the following post:

                                https://forum.qt.io/topic/79431/c-sqlite3-encrypted-db/5

                                This pluging was easy to compile directly through Qt, and no need to compile other files to make it work. The output is dlls which should just be put in the Qt sqldriver folder. This work with no problem, and I now got an encrypted database.

                                aha_1980A Offline
                                aha_1980A Offline
                                aha_1980
                                Lifetime Qt Champion
                                wrote on last edited by
                                #15

                                @AndersDK glad you found a solution.

                                So please mark this topic as SOLVED.

                                thanks

                                Qt has to stay free or it will die.

                                1 Reply Last reply
                                1

                                • Login

                                • Login or register to search.
                                • First post
                                  Last post
                                0
                                • Categories
                                • Recent
                                • Tags
                                • Popular
                                • Users
                                • Groups
                                • Search
                                • Get Qt Extensions
                                • Unsolved