c++sqliteqtqtplugin

Undefined reference after building SQLite plugin for Qt 6.5.1


I am trying to build SQLite3 plugin for Qt since I need to use SQLite specific hook functions. I have prebuilt Qt 6.5.1 on windows machine mingw_64 version. I have built plugin which works with qt functions but gives me undefined reference when I am trying to use any SQLite3 function.

I have tried the following from what Qt docs suggests:

  1. Downloaded SQLite 3.42.0 source (amalgamation) and windows binaries from here
  2. Compiled binaries into sqlite3.lib via CMD for VS 2017 with: "lib /DEF:sqlite3.def /OUT:sqlite3.lib /MACHINE:x64"
  3. configured via Qt 6.5.1 CMD with command: "qt-cmake -G Ninja C:\Qt\6.5.1\Src\qtbase\src\plugins\sqldrivers -DCMAKE_INSTALL_PREFIX=C:\Qt\6.5.1\mingw_64 -DCMAKE_INCLUDE_PATH=C:\libs\sqlite-amalgamation-3420000 -DCMAKE_LIBRARY_PATH=C:\libs\sqlite-amalgamation-3420000 -DFEATURE_system_sqlite=ON". All sqlite3 files (binaries and .c/.h) were in sqlite-amalgamation-3420000 folder.
  4. cmake --build .
  5. cmake --install .
  6. Using sqlite header file in my project tried to call a function which gives me error of undefined reference

Maybe someone can tell me on what I am doing wrong. Thanks in advance.


Solution

  • So the problem was that you should link to the SQLite library that you were building your plugin from (as the person in comments mentions). I thought that linkage to Qt SQLite was enough and I was wrong.