Compile static Qt with sqlite (or other plugin) with icu on Windows
[Update 29/08/2017]
– Work with ICU 54.1
– Work with ICU 55.1
– Work with ICU 56.1
First tested version
Qt 5.6.2 and icu 51.2
Introduction
Qt is an incredible tool which can be built on Windows, Linux, Embedded Software like iOS or Android. There is sqlite support and many other ODBC support. Static building is a good technology because you can provide your tool through cloud and other sharing systems without the need to provide many libraries. It also can be useful to include icu to provide language sorting (like E, Ê, D, e, é, è …). I will try to post other Qt tutorial especially concerning Qt and SQL.
Download list
Qt 5.6.2 sources Windows Host for MinGW 4.9.2: qt-opensource-windows-x86-mingw492-5.6.2.exe
ICU 51.2 sources: icu4c-51_2-src.zip
MSYS2: msys2-x86_64-20161025.exe
Python 3.6.2: python-3.6.2.exe
Compile ICU
Install msys2-x86_64-20161025.exe
Install qt-opensource-windows-x86-mingw492-5.6.2.exe with Qt Sources
Unzip icu4c-51_2-src.zip in C:\icu
Launch MSYS2 32 bits as an administrator
cd /c/icu/source
export PATH=/C/Qt/Qt5.6.2/Tools/mingw492_32/bin:$PATH
Not Static
./runConfigureICU MinGW –prefix=$PWD/../dist
Static
./runConfigureICU MinGW –prefix=$PWD/../dist –enable-static –disable-shared
mingw32-make && mingw32-make install
Compile Qt with sqlite-icu
Open cmd.exe as an administrator
set PATH=%PATH%;C:\Qt\Qt5.6.2\Tools\mingw492_32\bin
set PATH=%PATH%;C:\Users\smK-CERCERON\AppData\Local\Programs\Python\Python36-32
Not Static
cd C:\Qt\Qt5.4.1-static-sqlite-icu\5.4\Src\qtbase
mingw32-make distclean
mingw32-make clean
configure.bat -platform win32-g++ -confirm-license -nomake examples -nomake tests -skip qtwebkit -opengl desktop -no-compile-examples -nomake tests -plugin-sql-sqlite -opensource
mingw32-make
Static
cd C:\Qt\Qt5.6.2\5.6\Src
mingw32-make distclean
mingw32-make clean
configure.bat -platform win32-g++ -confirm-license -nomake examples -nomake tests -opengl desktop -no-compile-examples -nomake tests -plugin-sql-sqlite -static -opensource
mingw32-make
Configure sqlite (or other plugin) with icu
First of all, we need to modify the sqlite.pro file to allow icu to be attach with sqlite.
Open C:/Qt/Qt5.6.2/5.6/Src/qtbase/src/plugins/sqldrivers/sqlite/sqlite.pro and add after TARGET = qsqlite
Not Static
DEFINES += SQLITE_ENABLE_ICU
INCLUDEPATH += « C:/icu/dist/include »
LIBS += -L »C:/icu/dist/lib » -licuin -licuuc -licudt
Static
DEFINES += SQLITE_ENABLE_ICU
INCLUDEPATH += « C:/icu/dist/include »
LIBS += -L »C:/icu/dist/lib » -lsicuin -lsicuuc -lsicudt
Open cmd.exe as an administrator
set PATH=%PATH%;C:\Qt\Qt5.6.2\Tools\mingw492_32\bin
set PATH=%PATH%;C:\Qt\Qt5.6.2\5.6\Src\qtbase\bin
cd C:\Qt\Qt5.6.2\5.6\Src\qtbase\src\plugins\sqldrivers\sqlite
mingw32-make clean
mingw32-make distclean
qmake sqlite.pro
mingw32-make
Configuration of your .pro
There is only two line to add to the .pro of your project :
CONFIG += static
DEFINES += STATIC
But maybe there is no need for this, I will check later.
Results
The result of the building can be found in this folder : C:\Qt\Qt5.6.2\5.6\Src\qtbase\bin.
You can configure Qt Creator with this new kit.
Do not forget to clean your project and run qmake.exe
To clean any step
mingw32-make confclean
mingw32-make distclean
mingw32-make clean
Notes
This tutorial works also for :
– ICU 54.1
– ICU 55.1
– ICU 56.1
Sources
http://qt-project.org/wiki/Compiling-ICU-with-MinGW
http://wiki.qt.io/Compiling-ICU-with-MinGW
0 commentaire