Can't working MYSQL database in qt (QSqlDatabase: available drivers: QSQLITE QODBC QPSQL)
-
@Lestev You should really start to CAREFULLY read what others write and also try to understand what you are doing!
You are still using .<so|dylib> in your command and it should be actually apparent that you should replace it by what your platform requires (.dylib on Mac).You also should remove "-G Ninja" if you do not have Ninja.
Also you were asked to post TEXT not pictures, but you keep posting pictures. Is there a reason for that?
-
@jsulm wow! Thank you very much, I did this and succeeded, but the error remained, I added install_name_tool -change /usr/local/mysql-8.0.25-macos11-x86_64/lib/libmysqlclient.21.dylib /usr/local/mysql-8.0 . 25-macos11-x86_64/lib/libmysqlclient.21.dylib/Users/migellestv/Qt/6.2.3/macos/plugins/sqldrivers/libqsqlmysql.dylib
and I succeeded, but error remained:
QSqlQuery::exec: database not open
QSqlQuery::exec: database not open
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QODBC QPSQLWhy if i added install_name_tool?
-
@Lestev Did you also do this:
cmake --build . cmake --install .
-
@jsulm said in Can't working MYSQL database in qt (QSqlDatabase: available drivers: QSQLITE QODBC QPSQL):
Did you also do this:
Yes i successed :
cmake --build .
[9/11] Linking CXX shared module plugins/sqldrivers/libqsqlmysql.dylib
ld: warning: linking against a dylib which is not safe for use in application extensions: /usr/local/mysql/lib/libmysqlclient.dylib
[11/11] Linking CXX shared module plugins/sqldrivers/libqsqlite.dylib
migellestev@Migels-MacBook-Pro build-sqldrivers % cmake --install .
-- Install configuration: "RelWithDebInfo"
-- Installing: /Users/migellestev/Qt/6.2.3/macos/lib/cmake/Qt6Sql/Qt6QMYSQLDriverPluginConfig.cmake
-- Installing: /Users/migellestev/Qt/6.2.3/macos/lib/cmake/Qt6Sql/Qt6QMYSQLDriverPluginConfigVersion.cmake
-- Installing: /Users/migellestev/Qt/6.2.3/macos/lib/cmake/Qt6Sql/Qt6QMYSQLDriverPluginConfigVersionImpl.cmake
etc -
@Lestev OK, then we need to debug now.
Do this on console:- Go to the build folder of your application
- Do: export QT_DEBUG_PLUGINS=1
- Run your app from the terminal
- Copy paste the output from terminal to here
You can also set QT_DEBUG_PLUGINS in Run settings of your project in QtCreator.
https://doc.qt.io/qt-5/debug.html -
@jsulm Thanks, i get it, but how i can use run in terminal project?, i wrote:
migellestev@Migels-MacBook-Pro forBeginner % c++ main.cpp
main.cpp:1:10: fatal error: 'QGuiApplication' file not found
#include <QGuiApplication>
^~~~~~~~~~~~~~~~~
1 error generated. -
@jsulm hey, the terminal doesn't output anything, it only launches the application
migellestev@Migels-MacBook-Pro build-forBeginner-Clone_of_Qt_6_2_2_for_macOS-Debug % export QT_DEBUG_PLUGINS=1
migellestev@Migels-MacBook-Pro build-forBeginner-Clone_of_Qt_6_2_2_for_macOS-Debug % open forBeginner.app
migellestev@Migels-MacBook-Pro build-forBeginner-Clone_of_Qt_6_2_2_for_macOS-Debug %Everything works, but inside qt error is keeping
-
Don't call open, use the full path to the executable in the bundle.
-
@SGaist hi, I think my directory is not properly defined because it should be /Users/migellestev/Qt/6.2.3/macos/plugins/sqldrivers
but directory is:
/Users/migellestev/Qt/QtDesignStudio/qt6_design_studio_reduced_version/plugins/sqldriversif it helps:
-
Looks like you're mixing up Qt versions which is not possible. Make sure QtDesignStudio is not picked up, only your Qt6.2.2 where you also (hopefully) build your Qt mysql plugin for. Currently it looks like you created (or had by default - don't know) the plugin inside QtDesignStudio.
-
@Christian-Ehrlicher
Thanks for your response very much,
But i verify my path and got that this path used by default, but why?I reinstalled qt and got the same
-
Don't know MacOS but on linux this means you have the other somewhere in your LD_LIBRARY_PATH or ld.so.conf. Remove it /make sure the correct path comes first.
-
Hello!
Error
/Users/ilaproskurnev/Qt/6.2.3/macos/bin/qt-cmake: line 17: exec: cmake: not found
If export PATH="/Users/ilaproskurnev/Qt/6.2.3/macos/bin:$PATH"
qt-cmake -G Ninja /Users/ilaproskurnev/Qt/6.2.3/Src/qtbase/src/plugins/sqldrivers -DCMAKE_INSTALL_PREFIX=/Users/ilaproskurnev/Qt/6.2.3/macos -DMySQL_INCLUDE_DIR="/usr/local/mysql/include" -DMySQL_LIBRARY="/usr/local/mysql/lib/libmysqlclient.dylib"
line 17: exec: cmake: not found -
Then make sure that cmake is installed and in your PATH...
-
@Christian-Ehrlicher
Please tell me how to check it?
exec "$cmake_path" -DCMAKE_TOOLCHAIN_FILE="$toolchain_path" "$@" -
@Ilya-Pro said in Can't working MYSQL database in qt (QSqlDatabase: available drivers: QSQLITE QODBC QPSQL):
Please tell me how to check it?
I don't understand. If you want to build Qt or one of it's plugins you have to install cmake and make sure it's found in your PATH.
-
@Christian-Ehrlicher
QtToolchainHelpers.cmake
toolchain_path="$script_dir_path/../lib/cmake/Qt6/qt.toolchain.cmake"
screenshot