Building Qt SQLCipher driver
-
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.
-
Hi,
What exactly did you do ?
Which version of Qt are you using ?
Which version of cmake ?
For what exact version of Visual Studio ? -
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
-
Why not build it using Qt Creator ? That would simplify the setup process and ensure the build environment is correctly setup.
-
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
-
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
-
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} };
-
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} };
@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. -
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?
-
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?
@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. -
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.
-
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.
-
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.