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. MYSQL Drivers - How to install on Mac osx 10.7?
Forum Updated to NodeBB v4.3 + New Features

MYSQL Drivers - How to install on Mac osx 10.7?

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 5.6k Views 1 Watching
  • 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.
  • P Offline
    P Offline
    PhilWilkins
    wrote on last edited by
    #1

    This has got to be the most frustrating install for what is a very popular database.
    I have searched and read and searched and read for 2 days now about how to install the MYSQL drivers, and still no joy.

    I followed the instructions on how to build for mac osx which is the platform I am using

    so I ran qmake $QTDIR/qmake "INCLUDEPATH+=$MYSQLPATH/include" "LIBS+=-L$MYSQLPATH/lib -lmysqlclient_r" ./mysql.pro

    and i got the following output:
    @make -f Makefile.Debug
    g++ -c -pipe -g -gdwarf-2 -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -fvisibility=hidden -fvisibility-inlines-hidden -Wall -W -fPIC -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -DQT_SHARED -I/Users/philwilkins/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/default -I. -I/Users/philwilkins/QtSDK/Desktop/Qt/4.8.1/gcc/lib/QtCore.framework/Versions/4/Headers -I/Users/philwilkins/QtSDK/Desktop/Qt/4.8.1/gcc/include/QtCore -I/Users/philwilkins/QtSDK/Desktop/Qt/4.8.1/gcc/lib/QtSql.framework/Versions/4/Headers -I/Users/philwilkins/QtSDK/Desktop/Qt/4.8.1/gcc/include/QtSql -I/Users/philwilkins/QtSDK/Desktop/Qt/4.8.1/gcc/include -I/usr/local/mysql-5.5.25-osx10.6-x86_64/include -Idebug -F/Users/philwilkins/QtSDK/Desktop/Qt/4.8.1/gcc/lib -o debug/main.o main.cpp
    /Users/philwilkins/QtSDK/Desktop/Qt/4.8.1/gcc/bin/moc -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -DQT_SHARED -I/Users/philwilkins/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/default -I. -I/Users/philwilkins/QtSDK/Desktop/Qt/4.8.1/gcc/lib/QtCore.framework/Versions/4/Headers -I/Users/philwilkins/QtSDK/Desktop/Qt/4.8.1/gcc/include/QtCore -I/Users/philwilkins/QtSDK/Desktop/Qt/4.8.1/gcc/lib/QtSql.framework/Versions/4/Headers -I/Users/philwilkins/QtSDK/Desktop/Qt/4.8.1/gcc/include/QtSql -I/Users/philwilkins/QtSDK/Desktop/Qt/4.8.1/gcc/include -I/usr/local/mysql-5.5.25-osx10.6-x86_64/include -Idebug -F/Users/philwilkins/QtSDK/Desktop/Qt/4.8.1/gcc/lib -D__APPLE__ -D__GNUC__ ../../../sql/drivers/mysql/qsql_mysql.cpp -o debug/qsql_mysql.moc
    g++ -c -pipe -g -gdwarf-2 -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -fvisibility=hidden -fvisibility-inlines-hidden -Wall -W -fPIC -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -DQT_SHARED -I/Users/philwilkins/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/default -I. -I/Users/philwilkins/QtSDK/Desktop/Qt/4.8.1/gcc/lib/QtCore.framework/Versions/4/Headers -I/Users/philwilkins/QtSDK/Desktop/Qt/4.8.1/gcc/include/QtCore -I/Users/philwilkins/QtSDK/Desktop/Qt/4.8.1/gcc/lib/QtSql.framework/Versions/4/Headers -I/Users/philwilkins/QtSDK/Desktop/Qt/4.8.1/gcc/include/QtSql -I/Users/philwilkins/QtSDK/Desktop/Qt/4.8.1/gcc/include -I/usr/local/mysql-5.5.25-osx10.6-x86_64/include -Idebug -F/Users/philwilkins/QtSDK/Desktop/Qt/4.8.1/gcc/lib -o debug/qsql_mysql.o ../../../sql/drivers/mysql/qsql_mysql.cpp
    /Users/philwilkins/QtSDK/Desktop/Qt/4.8.1/gcc/bin/moc -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -DQT_SHARED -I/Users/philwilkins/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/default -I. -I/Users/philwilkins/QtSDK/Desktop/Qt/4.8.1/gcc/lib/QtCore.framework/Versions/4/Headers -I/Users/philwilkins/QtSDK/Desktop/Qt/4.8.1/gcc/include/QtCore -I/Users/philwilkins/QtSDK/Desktop/Qt/4.8.1/gcc/lib/QtSql.framework/Versions/4/Headers -I/Users/philwilkins/QtSDK/Desktop/Qt/4.8.1/gcc/include/QtSql -I/Users/philwilkins/QtSDK/Desktop/Qt/4.8.1/gcc/include -I/usr/local/mysql-5.5.25-osx10.6-x86_64/include -Idebug -F/Users/philwilkins/QtSDK/Desktop/Qt/4.8.1/gcc/lib -D__APPLE__ -D__GNUC__ ../../../sql/drivers/mysql/qsql_mysql.h -o debug/moc_qsql_mysql.cpp
    g++ -c -pipe -g -gdwarf-2 -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -fvisibility=hidden -fvisibility-inlines-hidden -Wall -W -fPIC -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -DQT_SHARED -I/Users/philwilkins/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/default -I. -I/Users/philwilkins/QtSDK/Desktop/Qt/4.8.1/gcc/lib/QtCore.framework/Versions/4/Headers -I/Users/philwilkins/QtSDK/Desktop/Qt/4.8.1/gcc/include/QtCore -I/Users/philwilkins/QtSDK/Desktop/Qt/4.8.1/gcc/lib/QtSql.framework/Versions/4/Headers -I/Users/philwilkins/QtSDK/Desktop/Qt/4.8.1/gcc/include/QtSql -I/Users/philwilkins/QtSDK/Desktop/Qt/4.8.1/gcc/include -I/usr/local/mysql-5.5.25-osx10.6-x86_64/include -Idebug -F/Users/philwilkins/QtSDK/Desktop/Qt/4.8.1/gcc/lib -o debug/moc_qsql_mysql.o debug/moc_qsql_mysql.cpp
    rm -f libqsqlmysql_debug.dylib
    g++ -headerpad_max_install_names -arch x86_64 -single_module -dynamiclib -Xarch_x86_64 -mmacosx-version-min=10.5 -o libqsqlmysql_debug.dylib debug/main.o debug/qsql_mysql.o debug/moc_qsql_mysql.o -F/Users/philwilkins/QtSDK/Desktop/Qt/4.8.1/gcc/lib -L/Users/philwilkins/QtSDK/Desktop/Qt/4.8.1/gcc/lib -L/usr/local/mysql/lib -lmysqlclient_r -framework QtSql -L/usr/local/pgsql/lib -L/tmp/qt-stuff-85167/source/qt-everywhere-opensource-src-4.8.1/Desktop/Qt/4.8.1/gcc/lib -F/tmp/qt-stuff-85167/source/qt-everywhere-opensource-src-4.8.1/Desktop/Qt/4.8.1/gcc/lib -framework QtCore
    ld: warning: directory not found for option '-L/usr/local/pgsql/lib'
    ld: warning: directory not found for option '-L/tmp/qt-stuff-85167/source/qt-everywhere-opensource-src-4.8.1/Desktop/Qt/4.8.1/gcc/lib'
    ld: warning: directory not found for option '-F/tmp/qt-stuff-85167/source/qt-everywhere-opensource-src-4.8.1/Desktop/Qt/4.8.1/gcc/lib'@

    it will not build the release and will only make the debug.

    What am i doing wrong here?

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tucnak
      wrote on last edited by
      #2

      Your Qt were built from sources, yes?

      1 Reply Last reply
      0
      • P Offline
        P Offline
        PhilWilkins
        wrote on last edited by
        #3

        Hi,

        I have not built Qt from sources - i downloaded and installed the SDK 1.2.1, and used the maintenance tool to install the sources, I then proceeded to build the mySQL drivers.

        any ideas?

        1 Reply Last reply
        0
        • T Offline
          T Offline
          tucnak
          wrote on last edited by
          #4

          OK. Can you link LIBS and INCLUDE directives in your .pro file. Then command will be just qmake and you will see errors through build process.

          And review $MYSQLPATH variable.

          1 Reply Last reply
          0
          • P Offline
            P Offline
            PhilWilkins
            wrote on last edited by
            #5

            Hi,

            I have managed to compile both debug and release versions, 2 files which have been placed into the plugins folder:

            libqsqlmysql_debug.dylib
            libqsqlmysql.dylib

            ~/QtSDK/Desktop/Qt/4.8.1/gcc/plugins/sqldrivers/

            in my project file for my database application i am writing, i have added 'sql'

            @QT += core gui sql@

            in my main window constructor - i have the code to open the database:

            @// Configure Database connection
            db = QSqlDatabase::addDatabase("QMYSQL");
            db.setHostName("localhost");
            db.setDatabaseName("WorkforceManager");
            db.setUserName("root");
            //db.setPassword("abc1234");
            db.setPort(3306);
            DBOk = db.open();
            qDebug() << db.drivers();
            qDebug() << db.lastError();@

            This compiles without any problems. However, when i run the application, it is saying the following:

            @QSqlDatabase: QMYSQL driver not loaded
            QSqlDatabase: available drivers: QSQLITE QODBC3 QODBC QPSQL7 QPSQL
            ("QSQLITE", "QODBC3", "QODBC", "QPSQL7", "QPSQL")
            QSqlError(-1, "Driver not loaded", "Driver not loaded")@

            do i need to tell Qt somehow about the new driver?

            1 Reply Last reply
            0
            • P Offline
              P Offline
              PhilWilkins
              wrote on last edited by
              #6

              finally worked it out!!

              final step after all of that you need to run the install-name-tool:
              @install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient_r.18.dylib libqsqlmysql.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