Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A detailled way to build it yourself #14

Open
ArrayIndexOutOfBound opened this issue May 31, 2021 · 8 comments
Open

A detailled way to build it yourself #14

ArrayIndexOutOfBound opened this issue May 31, 2021 · 8 comments

Comments

@ArrayIndexOutOfBound
Copy link

Hi,

I was wondering f it was possible to give me/us a small step by step tutorial on how to build for Linux and/or Windows?
I somehow managed to grasp how to build it in Windows, but it was after following way to much different tutorials on Internet, but since you seem to already master it, f you could share it would be great.

Thanks in advance.

@thecodemonkey86
Copy link
Owner

thecodemonkey86 commented Jun 3, 2021

Hi, this can be quite tricky and lots of things can go wrong. I try to describe the steps for Qt 5 on Ubuntu first, Qt 6 has a new build system (CMake), I'll add the steps for that and for Windows respectively later:

Some prerequisites before the actual building process:

  1. Install the libmysqlclient (if not already pre-installed)
    sudo apt install libmysqlclient21
  2. Install the libmysql development files
    sudo apt install libmysqlclient-dev
  3. Install Qt 5 using official installer, select Sources to be installed
    image
  4. Run the configure script in terminal. Assuming we installed Qt in /opt/Qt/5.12.11:
    cd /opt/Qt/5.12.11/Src
    sudo ./configure

Then for building:

  1. cd /opt/Qt/5.12.11/Src/qtbase/src/plugins
  2. sudo /opt/Qt/5.12.11/gcc_64/bin/qmake -- MYSQL_PREFIX=/usr/local
  3. cd sqldrivers/mysql
    There should be a Makefile in that folder which was created my the qmake command. check with ls
    image
  4. sudo make install
  5. if all went well, we are done, and the .so files are in /opt/Qt/5.12.11/gcc_64/plugins/sqldrivers/
    image

I hope I did't forget anything

@ArrayIndexOutOfBound
Copy link
Author

Hi, this seem to be exactly what I was looking for, that's great thanks. I will check if I manage to do it in the next 48h to keep you in check.
Not as important as making the plugin, but does this work on an Android device? Just for general knowledge, I can't really see any use of a MySql connection on an Android app.

@ArrayIndexOutOfBound
Copy link
Author

Here I am again, I can't even manage to install QT on my Raspberry.
I don't really understand why, but the qt-unified-XXXX.run don't seem to be working even though I have set the file to be executable, so I can't really give you a feedback about the tutorial, even since it seems to be good.

@thecodemonkey86
Copy link
Owner

is maybe this library missing:
sudo apt install libxkbcommon-x11-0
? This was the cause for me recently that the Qt installer didn't run at first.

As for Android: I have no experience with Qt on Android, so I don't know at the moment

@codewirrwarr
Copy link

Hi, any change to get a windows tutorial?

@zaiplanet
Copy link

you can make tutorial for qt 6.3 on ubuntu or windows?

@thecodemonkey86
Copy link
Owner

thecodemonkey86 commented Jul 23, 2022

Sorry for the long delay, but I couldn't get it to work using cmake on Windows earlier. Anyway, here are 2 batch files for Windows cmd, that might help. You must of course adjust the paths and version numbers accordingly

for MSVC:

Prerequisites:

  1. Install MSVC Compiler (from Visual Studio 2022 Setup)
  2. Install Qt incl. Sources, CMake and Ninja from Maintenance Tool
  3. Install MySQL library, e.g. by using Oracle's Installer or use the zip file from here
set PATH=%PATH%;C:\Qt\Tools\CMake_64\bin;C:\Qt\Tools\Ninja
cd C:\Qt\6.4.0\Src\qtbase\src\plugins\sqldrivers
call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
call C:\Qt\6.4.0\msvc2019_64\bin\qt-cmake.bat -G "Ninja" . -DMySQL_INCLUDE_DIR="C:\mysql_8.0.29\include" -DMySQL_LIBRARY="C:\mysql_8.0.29\lib\libmysql.lib" -DCMAKE_INSTALL_PREFIX="C:\Qt\6.4.0\msvc2019_64"
ninja
ninja install
call C:\Qt\6.4.0\msvc2019_64\bin\qt-cmake.bat -G "Ninja" . -DMySQL_INCLUDE_DIR="C:\mysql_8.0.29\include" -DMySQL_LIBRARY="C:\mysql_8.0.29\lib\libmysql.lib" -DCMAKE_INSTALL_PREFIX="C:\Qt\6.4.0\msvc2019_64" -DCMAKE_BUILD_TYPE=Release
ninja
ninja install
pause

for MinGW:

Prerequisites:

  1. Install Qt incl. Sources, CMake and MinGW from Maintenance Tool
  2. Install MySQL library, e.g. by using Oracle's Installer or use the zip file from here
set PATH=%PATH%;C:\Qt\Tools\mingw1120_64\bin;C:\Qt\Tools\CMake_64\bin
cd C:\Qt\6.4.0\Src\qtbase\src\plugins\sqldrivers
call C:\Qt\6.4.0\mingw_64\bin\qt-cmake.bat -G "MinGW Makefiles" . -DMySQL_INCLUDE_DIR="C:\mysql_8.0.29\include" -DMySQL_LIBRARY="C:\mysql_8.0.29\lib\libmysql.lib" -DCMAKE_INSTALL_PREFIX="C:\Qt\6.4.0\mingw_64" -DCMAKE_C_COMPILER="gcc.exe" -DCMAKE_CXX_COMPILER="g++.exe"
mingw32-make
mingw32-make install
pause

@peakoptions
Copy link

What can I do to build drivers for android using Qt5 on windows

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants