Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Creating mysql driver in mac
QtWS25 Last Chance

Creating mysql driver in mac

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 120 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.
  • S Offline
    S Offline
    sdithoney
    wrote on last edited by
    #1

    Hi Team,
    I am very new to the qt. In a recent project I was needed to connect a macos desktop app with mysql database. I have faced several issues. While configuring the driver, I followed multiple threads to search. I am trying here to put all my findings in a single place. Lets Start point wise.

    • Download mysql with arm 64 architecture from oracle website.
    • I have used Qt 6.5.3, so assuming that you have installed it from Qt online installer and your Qt path in macOs is /User/<username>/Qt.
    • I am assuming the mysql path is /usr/local/mysql.
    • Create a folder anywhere I have used /User/<username>/build-sqldrivers. Created using command "mkdir build-sqldrivers".
    • Navigate inside the folder using cd build-sqldrivers.
    • Please install ninja using brew install ninja.
    • Use below command to create the driver:
      /Users/user/Qt/6.5.3/macos/bin/qt-cmake -G Ninja /Users/user/Qt/6.5.3/Src/qtbase/src/plugins/sqldrivers DCMAKE_INSTALL_PREFIX=/Users/user/Qt/6.5.3/macos -DMySQL_INCLUDE_DIR="/usr/local/mysql/include/" -DMySQL_LIBRARY="/usr/local/mysql/lib/libmysqlclient.24.dylib" -DCMAKE_OSX_ARCHITECTURES="arm64"
    • Next run the below command :
      sed -i -e 's/-arch x86_64/-arch arm64/g' /Users/user/build-sqlrivers/build.ninja
    • Next run :
      cmake --build .
    • In the next step run install :
      cmake --install .
    • If all the above steps are executed successfully you can find the library files in Qt/6.5.3/macos/plugin/sqldrivers, however if you run the qt code, you may face the same error. If the error persist, please follow the below steps.
    • Check for the architecture of QtCore and libqsqlmysql.dylib, using the below commands , both should be same for me it is arm 64.
      ** command 1 "file /Users/user/Qt/6.5.3/macos/lib/QtCore.framework/QtCore" without quote.
      ** command 2 "file /Users/honeysharma/Qt/6.5.3/macos/plugins/sqldrivers/libqsqlmysql.dylib" without quote.
    • Please check your code again it should now resolve the architecture error.
    • Last step, please link the sql driver from mysql to /Qt/macos/plugin/sqldrivers using below command.
      ** ln -s /usr/local/mysql/lib/libmysqlclient.24.dylib /Users/user/Qt/6.5.3/macos/lib/libmysqlclient.24.dylib
    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