Monday, April 02, 2018

First steps with Lazarus Qt5 interface

Steps for building and installing Qt5 for Lazarus

Using a quick test project with relevant code shown here: unit1.pas
I'm using Qt 5.6.2 because that's the version with which Lazarus qt5 interface has been tested. You can experiment with later versions, too.

Windows 32-bit

Using MinGW

$(LazarusDir): C:\fpcupdeluxe\lazarus
$(QtDir): C:\Qt\Qt5.6.2

- download: qt-opensource-windows-x86-mingw492-5.6.2.exe
- install
- open command prompt in the bindings directory $(LazarusDir)\lcl\interfaces\qt5\cbindings
set PATH=$(QtDir)\5.6\mingw49_32\bin;$(QtDir)\Tools\mingw492_32\bin;%PATH%
qmake
mingw32-make
mingw32-make install
$(FpcDir)\bin\i386-win32\strip.exe $(QtDir)\5.6\mingw49_32\bin\Qt5Pas1.dll



Windows 64-bit

Using Visual Studio 2015

$(LazarusDir): C:\fpcupdeluxe\lazarus
$(QtDir): C:\Qt\Qt5.6.2

- download: qt-opensource-windows-x86-msvc2015_64-5.6.2.exe
- install
- fix the binding sources in the bindings directory $(LazarusDir)\lcl\interfaces\qt5\cbindings to be able to compile with Visual Studio: patch
- open command prompt in the bindings directory $(LazarusDir)\lcl\interfaces\qt5\cbindings
set PATH=$(QtDir)\5.6\msvc2015_64\bin;%PATH%
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
qmake

- edit the Makefile to remove -Wfatal-errors from CXXFLAGS
nmake
nmake install



OSX 64-bit

$(LazarusDir): ~/fpcupdeluxe/lazarus
$(QtDir): ~/Qt5.6.2

- download: qt-opensource-mac-x64-clang-5.6.2.dmg
- install
- open terminal in the bindings directory $(LazarusDir)/lcl/interfaces/qt5/cbindings
PATH=$(QtDir)/5.6/clang_64/bin:$PATH
qmake
make
sudo make install



Linux 64-bit (Mint 18.3 Sylvia)

$(LazarusDir): ~/fpcupdeluxe/lazarus
$(QtDir): ~/Qt5.6.2

- make sure OpenGL headers are installed:
sudo apt install mesa-common-dev
sudo ln -s /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1 /usr/lib/libGL.so
sudo ldconfig

- download: qt-opensource-linux-x64-5.6.2.run
- install
Modify the system-wide config in /usr/lib/x86_64-linux-gnu/qt-default/qtchooser/default.conf to point to your Qt5 directories:
$(QtDir)/5.6/gcc_64/bin
$(QtDir)/5.6/gcc_64/lib

- open terminal in the bindings directory $(LazarusDir)/lcl/interfaces/qt5/cbindings
qmake
make
sudo make install
sudo strip $(QtDir)/5.6/gcc_64/lib/libQt5Pas.so.1.2.6



Happy Easter!

No comments: