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. QMYSQL and CMAKE

QMYSQL and CMAKE

Scheduled Pinned Locked Moved Installation and Deployment
3 Posts 2 Posters 6.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.
  • G Offline
    G Offline
    goocreations
    wrote on last edited by
    #1

    Hi,

    I'm trying to compile an application with Qt's MYSQL driver and cmake. Everything compiles correctly, but when I start the application, I'm getting the following error:

    @QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE@

    Since my compilation works, I think it has something to do with the linking. I'm using Ubuntu and have installed the driver via apt-get: libqt4-sql-mysql.

    Must I recompile Qt from source to include the driver, or should installing the library like I did work?
    I've added the the necessary cmake code:

    @SET(QT_USE_QTSQL TRUE)
    FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui QtSql REQUIRED)
    IF(QT_FOUND)
    INCLUDE(${QT_USE_FILE})
    IF(QT_QTSQL_FOUND)
    INCLUDE_DIRECTORIES(${QT_QTSQL_INCLUDE_DIR})
    ELSE(QT_QTSQL_FOUND)
    MESSAGE(FATAL ERROR "Qt SQL libraries missing.")
    ENDIF(QT_QTSQL_FOUND)
    ELSE(QT_FOUND)
    MESSAGE(FATAL ERROR "Qt4 not found.")
    ENDIF(QT_FOUND)

    ADD_EXECUTABLE(BCluster
    ${BC_SOURCES}
    ${BC_WRAP_HEADERS}
    ${BC_WRAP_RESOURCES}
    ${BC_WRAP_UI}
    )

    TARGET_LINK_LIBRARIES(BCluster
    ${QT_LIBRARIES}
    ${QT_QTSQL_LIBRARIES}
    )@

    1 Reply Last reply
    0
    • A Offline
      A Offline
      alexisdm
      wrote on last edited by
      #2

      You don't have to recompile Qt, just the plugin if it comes to that...

      Did you install Qt via apt-get too ?

      1 Reply Last reply
      0
      • G Offline
        G Offline
        goocreations
        wrote on last edited by
        #3

        Yes, I've installed Qt via apt-get too

        1 Reply Last reply
        0

        • Login

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