1

I am trying to use SQLCipher within my QT C++ project. I am running a windows machine and I have used steps explained in here (until end of step 5) to generate my sqlite3.h, sqlite3.c, sqlcipher.exe and sqlite3.dll. Hopefully, now I have an executable that works fine but I am trying to make use of SQLCipher within my QT project. I want to add sqlite3.h and sqlite3.dll to my project and use its functions to work with databases. I have copied sqlite3.h and sqlite3.dll from sqlcipher-master into my project. My .pro file looks like this:

HEADERS +=\
sqlcipher/sqlite3.h \
myOtherHeaderFiles.\
QMAKE_CXXFLAGS += -DSQLITE_OS_WIN=1 -DSQLITE_HAS_CODEC -DSQLITE_TEMP_STORE=2 -ldl -lpthread
LIBS+="path\to\project\sqlite3.dll"

When I try to build my project no compiling error occurs but when I try to run it I get:

11:55:15: Starting path\to\project\build-project-Desktop_Qt_5_14_1_MinGW_32_bit-Debug\project.exe ...
11:55:15: The program has unexpectedly finished.
11:55:15: The process was ended forcefully.
11:55:15: path\to\project\build-project-Desktop_Qt_5_14_1_MinGW_32_bit-Debug\project\build-project-Desktop_Qt_5_14_1_MinGW_32_bit-Debug\project.exe crashed.

Do I miss something important? Do I copy the wrong files or is there anything more to add to my project before building it? if you have had the experience of using SQLCipher in a QT+mingw project please leave a comment or guide me through.

NewUser
  • 87
  • 12
  • 1
    "crashed" could mean anything. Run it under a debugger so we can at least see the crash location or cause. Do you get any useful error if you run the program directly? – Botje Sep 04 '20 at 07:43
  • @Botje I tried to run my `.exe` using `QT console`. It said `sqlite3.dll` not found. I copied the file into the folder and now it runs. I have used a static path in my `.pro` to `.dll` file, so I was expecting it to run without a problem. It seems like the problem is solved. I will try to test encryption and leave another comment. – NewUser Sep 04 '20 at 08:00
  • 1
    Windows executables only store the module name (=filename) of dependent libraries, not the full path. At runtime you are at the mercy of the [library search order](https://learn.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order) – Botje Sep 04 '20 at 08:03

0 Answers0