2

I will preface that I don't really have any experience using cmake or building C++ projects in general (I'm sure that will become obvious).

I am having problems getting the MySQL driver and using it with Qt 6 on Ubuntu 22.04.

I was following the official guide, which list the following commands:

mkdir build-sqldrivers
cd build-sqldrivers
qt-cmake -G Ninja <qt_source_directory>/qtbase/src/plugins/sqldrivers -DCMAKE_INSTALL_PREFIX=<qt_installation_path>/<platform> -DMySQL_ROOT="/usr/local/mysql"
cmake --build .
cmake --install .

I ran into some problems:

  1. I don't know which directory I was even supposed to run these commands in.
  2. qt-cmake wasn't found as a command, and although this lead me to believe that it is normally included with the Qt 6 installation, I couldn't find it in any /bin folder I could see.
  3. I don't know what qt_source_directory implies. There is a directory ~/Qt, but does it mean ~/Qt or ~/Qt/<version>, or something else entirely?

I found this which said to use cmake in place of qt-cmake on Linux, but cmake -G Ninja's output makes me think it requires CMakeLists.txt to be in the project file, which it isn't since I used qmake to create the project. Attempting to use the command qmake proclaims that I don't have Qt 5 installed, so now I don't know if I installed it properly.

Many directions I found, including the official guide, also said to install some variant of libmysqlclient.<something> or libmysqlclient-<something>, but I don't have enough knowledge on their differences to know which is correct.

2
  • Are you trying to compile a third party program? Because if you were developing a Qt based program, most of what you asked should have theoretically been already addressed (and probably clear) way before attempting to build the MYSQL plugin. We also know nothing about your OS nor how you installed Qt, making it difficult to answer you to begin with. But note that if you're trying to build a program written by others, then you're not having a programming problem, but an issue with a program (the fact that you're trying to build it is relatively relevant), therefore the question is quite OT. Commented Feb 19 at 4:11
  • @musicamante I didn't intend to make it seem like I was compiling another's code. I needed to connect to a MySQL database in a project initialized with Qt Creator, and I saw that Qt had an available plugin to accomplish that. I installed Qt through the online installer, but I had trouble installing the plugin. I'm not really sure what other important information I could give about the OS other than what I already did, but it's 64-bit Ubuntu 22.04.5 LTS with GNOME version 42.9. Also, I don't know what "OT" is an acronym for. Commented Feb 19 at 5:04

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.