Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Error linking to target QSQLite with cmake
Forum Updated to NodeBB v4.3 + New Features

Error linking to target QSQLite with cmake

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
cmakeqt5sqlsqlitedebianqt5.15.2
2 Posts 2 Posters 1.1k 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.
  • H Offline
    H Offline
    Heych
    wrote on 16 Feb 2022, 06:43 last edited by
    #1

    Hello, I am attempting to build a project usingI am attempting to build a CMake project that uses QSQLite. I am using Debian 11 (bullseye) and have installed through the apt server qtdeclarative5-dev , libqt5sql5 and libqt5sql5-sqlite with no errors.

    The CMake file uses find_package(Qt5Sql) to locate the sql package but fails to find the sqlite install. My pc has the libqsqlite.so located in the directory /usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers and the Qt5SqlConfig.cmake is found and located in the /usr/lib/x86_64-linux-gnu/cmake/Qt5Sql. Qt5SqlConfig.cmake and Qt5SqlConfigVersion.cmake are the only files located in that directory and there is are no plugins for SQLite on my system.

    When I run the cmake (3.22.1) command I get the following error:

    CMake Error at CMakeLists.txt:113 (add_executable):
      Target "dvr" links to target "Qt5::QSQLiteDriverPlugin" but the
      target was not found.  Perhaps a find_package() call is missing for an
      IMPORTED target, or an ALIAS target is missing?
    

    I found on this Github the Qt5Sql_QSQLiteDriverPlugin.cmake file which I copied into the /usr/lib/x86_64-linux-gnu/cmake/Qt5Sql with the Qt5SqlConfig.cmake with the libqsqlite.so file but it also gives an error:

    CMake Error at CMakeHelpers/FindQt5Sql_QSQLiteDriverPlugin.cmake:3 (_populate_Sql_plugin_properties):
      _populate_Sql_plugin_properties Macro invoked with incorrect arguments for
      macro named: _populate_Sql_plugin_properties
    Call Stack (most recent call first):
      CMakeLists.txt:103 (find_package)
    

    I changed the Qt5Sql_QSQLiteDriverPlugin.cmake file to

    add_library(Qt5::QSQLiteDriverPlugin MODULE IMPORTED)
    
    # _populate_Sql_plugin_properties(QSQLiteDriverPlugin RELEASE "sqldrivers/libqsqlite.so")
    _populate_Sql_plugin_properties(RELEASE QSQLiteDriverPlugin "sqldrivers/libqsqlite.so" FALSE)
    
    list(APPEND Qt5Sql_PLUGINS Qt5::QSQLiteDriverPlugin)
    

    But this also gives an error:

    CMake Error at /usr/lib/x86_64-linux-gnu/cmake/Qt5Sql/Qt5SqlConfig.cmake:228 (set_property):
      set_property could not find TARGET Qt5::RELESE.  Perhaps it has not yet
      been created.
    Call Stack (most recent call first):
      /usr/lib/x86_64-linux-gnu/cmake/Qt5Sql/Qt5Sql_QSQLiteDriverPlugin.cmake:4 (_populate_Sql_plugin_properties)
      /usr/lib/x86_64-linux-gnu/cmake/Qt5Sql/Qt5SqlConfig.cmake:240 (include)
      CMakeLists.txt:102 (find_package)
    

    Can someone offer me some wisdom and help in adding sqlite to my program. I would like to stay away from building QT from source and using prebuilt Debian libraries if possible.

    Thanks in advance.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 16 Feb 2022, 06:44 last edited by
      #2

      You do not link against a plugin - it's loaded dynamically during runtime.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      2

      2/2

      16 Feb 2022, 06:44

      • Login

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