Reputation: 1757
I have compiled QT-5.8 from github successfully, each submodule is cloned by init-repository provided by QT. However, in Qt5.8, it has removed qtwebkit.
But my app needs qtwebkit, so I clone qtwebkit submodule and qmake it.
However, it shows the compilation errors
( test -e Makefile.api || /usr/local/Qt-5.8.0/bin/qmake -o Makefile.api /home/tumh/qt5/qtwebkit/Source/api.pri ) && make -f Makefile.api
make[1]: Entering directory '/home/tumh/qt5/qtwebkit/Source'
make[1]: *** No rule to make target '/home/tumh/qt5/qtwebkit/Source/WebCore//libWebCore.a', needed by '../lib/libQt5WebKit.so.5.8.0'. Stop.
make[1]: Leaving directory '/home/tumh/qt5/qtwebkit/Source'
Makefile:40: recipe for target 'sub-api-pri-make_first-ordered' failed
make: *** [sub-api-pri-make_first-ordered] Error 2
I have no idea that how to compile a single submodule in QT.
Any suggestion is appreciated.
thanks!
Upvotes: 1
Views: 3409
Reputation: 803
The following describes how to compile qtwebkit module so it is usable with Qt 5.9.9. I assume the process is similar if not identical for Qt 5.8.
All of the required components should be compiled using one tool chain. I suggest using the one installed with Qt.
You gonna need ICU compiled, the source code can be obtained from the official site.
The source code of qtwebkit module that we want to compile is available here (thx @J. Doe for the link!)
Regardless of the operating system you are working on, in order to compile qtwebkit module you gonna need the following additional tools:
Qtwebkit module depends on declarative
module. It becomes available when qtquick1 is installed.
It is assumed that Qt 5.9.9 is installed. I was using these installers.
The process takes some time so if you need the module ready ASAP go to the last section (What if you cannot perform some of the above steps).
On Windows I recommend using chocolatey
to install additional tools.
Install msys2
package via chocolatey. It allows to use the scrips provided with ICU source code with very few modifications.
Installation script requires make
program available. It doesn't matter if mingw32-make
is virtually (of even literally) the same tool. Copy mingw32-make.exe and rename it to make.exe.
Using cmd with integrated mingw tools (installed along with Qt) open msys2 shell forwarding the PATH variable.
msys2_shell -use-full-path
Go to the ICU source code directory (mine was C:\icu\source) and run
./runConfigureICU MinGW -prefix=$PWD/../dist
(It is expected to encounter "unknown platform" issue, no worries) Now run:
gcc -dumpmachine
Save the output, in my case it was i686-w64-mingw32
.
Using this result execute:
./configure -build=i686-w64-mingw32 -prefix=$PWD/../dist
(modify build
parameter according to the result of the previous step)
Now, you should be able to compile ICU with:
make & make install
(If you want to speed things up you can engage multiple CPU cores in the above process. For example in order to engage 777 cores execute make -j777 & make install
)
Assuming your ICU source code was in C:\icu\source directory, the result of the compilation should be in C:\icu\dist.
As said in the first section, compiling qtwebkit module requires additional tools. They can be installed via chocolatey using the following command:
choco install ruby gperf winflexbison python2
This, among others, installs win_flex.exe
and win_bison.exe
. As of this writing these executables are located (at least in my case) in C:\ProgramData\chocolatey\lib\winflexbison\tools .
The qmake checks for programs named bison.exe
and flex.exe
. So I have copied both win_flex.exe
and win_bison.exe
and renamed them flex.exe
and bison.exe
accordingly.
The last step is to add both of these programs to PATH variable. To do so execute (in cmd with integrated mingw tools) the following command:
set PATH=C:\ProgramData\chocolatey\lib\winflexbison\tools;%PATH%
Additionally you need to point to the directory where includes and libs of compiled ICU are located. I have done it like this:
set PATH=C:\icu\dist\bin;%PATH%
set INCLUDE=C:\icu\dist\include;
set LIB=C:\icu\dist\lib;
Above assumes that prior to executing this commands there was no variables named INCLUDE
and LIB
set in the currently used cmd.
Finally, qmake process checks for a variable named SQLITE3SRCDIR
.
As suggested by this answer you can set it to sqlite sources provided with Qt. In my case it was done like this:
set SQLITE3SRCDIR=C:\Qt\Qt5.9.9\5.9.9\Src\qtbase\src\3rdparty\sqlite
Now (using the same cmd) go to the directory where Qt sources are located and execute configure.bat
. I have done both of these steps with:
cd C:\Qt\Qt5.9.9\5.9.9\Src
configure.bat
Finally, extract the downloaded source code of the qtwebkitmodule to the sources directory of Qt (C:\Qt\Qt5.9.9\5.9.9\Src in my case) and make a module. I have done it like this:
cd qtwebkit-opensource-src-5.9.0
mkdir build
cd build
qmake -r ..
make
make install
It is strongly recommended to utilize multiple cores in the make
process, otherwise prepare yourself for a very long compilation.
Now you should be able to use webkit
and webkitwidgets
in your Qt projects.
I suggest using compilation tools provided with Qt instead of default make and g++ compiler. To do so I have exported path to the tools provided with Qt like this:
export PATH=/home/$USER/Qt5.9.9/5.9.9/gcc_64/bin/:$PATH
You gonna need ICU compiled. I suggest using version 56.1 as it is the same shipped with Qt 5.9.9. The compilation process is almost identical as it was described for Windows. the only difference is that you run:
./runConfigureICU Linux/gcc --prefix=$PWD/../dist
and later configure
script can be omitted on Linux.
On lUbuntu 18.04 I needed the following packages installed:
apt-get install ruby bison gperf python flex perl libx11-dev xserver-xorg-dev xorg-dev libpulse-dev libsqlite3-dev
As with compiling qtwebkit on Windows, you gonna need qtquick1
module installed.
I have encountered an error saying that some headers related to OpenGL were missing. If you have the same problem then in my case installing libgl1-mesa-dev
package solved it.
Now extract source code of qtwebkit module sources directory of your Qt installation. In my case it was "/home/$USER/Qt5.9.9/5.9.9/Src".
Modify WTF.pri file and add the path to ICU includes and libs after the first INCLUDEPATH. In my case it was done like this:
...
INCLUDEPATH += /home/$USER/icu/dist/include/
LIBS += -L/home/$USER/icu/dist/lib/
...
Note '-L' is placed before path pointing to libs.
Now you should be able to compile qtwebkit module in usual manner:
mkdir build
cd build
qmake -r ..
make & make install
You can always try to use prebuild binaries: https://download.qt.io/snapshots/ci/qtwebkit/5.9/latest/qtwebkit/ or unofficial fork of the qtwebkit module: https://github.com/qtwebkit/qtwebkit/releases
Upvotes: 0
Reputation: 429
You should take tarball of webkit from official releases. It should build fine with Qt-5.8.
Upvotes: 2