Project ERROR: Unknown module(s) in QT: webkitwidgets
Solution 1
You need to install the webkitwidgets library.
On Ubuntu, try this in a terminal:
sudo apt-get install libqt5webkit5-dev
On Fedora, the package has a different name, thus try:
sudo apt-get install qt5-qtwebkit-devel
Or on Fedora, via dnf:
sudo dnf install qt5-qtwebkit-devel
Solution 2
If you need to install the webkit* Windows library for Qt 5.7 you should compile it manually because in new version webkit (WebView?) replaced by WebEngine.
Read about Qt 5.7 release (comments): http://blog.qt.io/blog/2016/06/16/qt-5-7-released/
Build sequence (static OR shared):
1) Download Qt 5.7.0 sources: http://download.qt.io/community_releases/5.7/5.7.0/
2) Download required tools: ActiveState Perl (binary), Python (binary), Ruby (binary), GnuWin Bison (binary), GPref (binary), Grep (binary), WinFlex, LibIconv, make (binary), sqlite (source!), ICU (source), windows msys (binary) (unix like shell with the tools), mingw-w64 (bin+dev) for build Qt with QtWebKit, see link on: https://trac.webkit.org/wiki/BuildingQtOnWindows
3) After download ICU source into C:\icu\icu. Open msys QT mingw console shell by open Start windows menu (msys should be downloaded and installed) and search or use fast search. In opened console start configure script and then compile and install:
$ cd C:\icu\icu\source
$ ./runConfigureICU
$ set PATH=%PATH%;C:\msys\1.0\bin\
$ make.exe
$ make.exe install
4) Build Qt with(!) ICU support (set "-icu" to configure) see compile script below. Change PATH to your environment.
Directory structure:
- C:\Qt\5.7.0 - download binary version of Qt 5.7.0 here
- C:\Qt\5.7.0n - directory for new (compiled) version of 5.7.0 (just make dir)
- C:\Qt\Src - download source of Qt 5.7.0 here
C:\Qt\Src\qtbase\compile.bat
set INCLUDE=C:\icu\icu\dist\include
set LIB=C:\icu\icu\dist\lib
set QTDIR=C:\Qt\5.7.0n
set PATH=%PATH%;C:\Qt\Qt5.7.0\5.7\mingw53_32\bin;C:\Qt\Qt5.7.0\Tools\QtCreator\bin;C:\Qt\Qt5.7.0\Tools\mingw530_32\bin;C:\Qt\Src\qtbase\bin;C:\Program Files (X86)\GnuWin32\bin;C:\winflex;C:\Ruby23-x64\bin;C:\Python27;C:\mingw-w64\i686-1\mingw32\bin;C:\icu\bin
set QMAKESPEC=win32-g++
set BUILD_DIR=C:\Qt\Qt5.7.0n
call C:\Qt\Src\qtbase\configure.bat -prefix %BUILD_DIR% -platform %QMAKESPEC% -confirm-license -debug-and-release -opensource -opengl desktop -no-compile-examples -icu -I C:/icu/icu/dist/include -L C:/icu/icu/dist/lib
jom.exe -j 4
pause
Run command in exmaple in Windows Power Shell:
$ cd C:\Qt\Src\qtbase
$ ./compile.bat
After pass through compile use it to install files in the BUILD_DIR (install Qt files):
$ C:\mingw-w64\i686-1\mingw32\bin\mingw32-make.exe install
Qt should start to install
5) Download Qtwebkit sources to C:\Qt\Src\qtwebkit. Use compile script below to compile the qtwebkit using new Qt 5.7.0 build with files in C:\Qt\5.7.0n with ICU.
C:\Qt\Src\qtwebkit\Tools\Scripts\compile.bat
set INCLUDE=C:\sqlite
set LIBS=C:\sqlite
set SQLITE3SRCDIR=C:\sqlite
set QTDIR=C:\Qt\Qt5.7.0n
set PATH=%PATH%;C:\Qt\Qt5.7.0n\bin;C:\Qt\Src\qtbase\bin;C:\winflex;C:\Ruby23-x64\bin;C:\Python27;C:\mingw-w64\i686-1\mingw32\bin;C:\icu\bin;C:\Program Files (x86)\GnuWin32\bin
set QMAKESPEC=win32-g++
call perl.exe .\build-webkit --qt --release
Compile the qtwebkit:
$ cd C:\Qt\Src\qtwebkit\Tools\Scripts
$ ./compile.bat
$ cd C:\Qt\Src\qtwebkit\WebKitBuild\Release
$ C:\mingw-w64\i686-1\mingw32\bin\mingw32-make.exe install
It should be possible to compile your application with the qtwebkit after successfull compile and install.
BUILD QT FOR STATIC
Edit file C:\Qt\Src\qtbase\compile.bat and pass through build.
...
call C:\Qt\Src\qtbase\configure.bat -prefix %BUILD_DIR% -platform %QMAKESPEC% -confirm-license -debug-and-release -opensource -opengl desktop -static -no-compile-examples -icu
echo "QMAKE_FLAGS += -static -static-libgcc" >> .mkspecs/%QMAKESPEC%/qmake.conf
...
POSSIBLE ERRORS
1) While build qtwebkit: "fatal error: unicode/uchar.h: No such file or directory"
Check that your Qt 5.7.0n build with ICU. IT also could notify you about "ICU required" at configure in qtwebkit.
2) flex: unknown flag '-'. For usage, try
You should use correct version of Flex that is "win_flex" in this case. You should rename files to use win_flex instead of just flex (and bison).
1) rename C:\Program Files (x86)\GnuWin32\bin\flex.exe to some unused name.
2) rename C:\Program Files (x86)\GnuWin32\bin\bison.exe to some unused name.
3) rename C:\winflex\win_bison.exe to bison.exe.
3) While build qtwebkit: "fatal error: sqlite3.h: No such file or directory"
Edit file C:\Qt\Src\qtwebkit\Tools\Scripts\compile.bat and check for correct path to sqlite:
set SQLITE3SRCDIR=C:\(path to some SQLITE .h/source files)
4) skipping incompatible ... when searching for ...
You should download right library arch (32bit or 64bit)
5) View.cpp ... undefined reference to WKPageCanGoBack
Could happens when pass through some test or MiniBrowser. You can search in files for the "UIProcess/API/qt" and "MiniBroswer" and remove it from Makefile's and some other files and then start build again.
LINKS
Build Qt5: https://wiki.qt.io/Building_Qt_5_from_Git Qt WebKit build
like how to: https://trac.webkit.org/wiki/BuildingQtOnWindows ICU
build with GNU: https://wiki.qt.io/Compiling-ICU-with-MinGW
Solution 3
The community builds referenced by Alex are only available until Qt 5.9. If you want to use newer Qt5 (current version is 5.11), then another option is to port "QtWebKit" to "QtWebEngine".
See: https://wiki.qt.io/QtWebEngine/Porting_from_QtWebKit
Solution 4
I got it to work by copying the webkit and webkitwidgets pri files from a previous installation, 5.5.
~/Qt/5.5/clang_64/mkspecs/modules/
Solution 5
For windows, I just downloaded https://github.com/annulen/webkit/releases/tag/qtwebkit-tp5 and copied the folders to relevant Qt installation folder. Now I can use MinGW Qt5.8 with latest webkit. Thanks to Konstantin and all the contributors for this project!
Only one thing to note - I needed to use the release configuration in Qt.
Related videos on Youtube
Comments
-
user1251007 almost 2 years
I am porting code from qt4 to qt5. I added the following line to my
.pro
file, as suggested:QT += webkitwidgets
However, when I run
qmake
, I get the this error:Project ERROR: Unknown module(s) in QT: webkitwidgets
I am developing on Ubuntu 12.04 LTS and installed Qt as described.
-
Ionică Bizău over 9 yearsIs there any solution for OS X?
-
Wboy about 8 yearsHey, i tried this but it still throws the same error. Is there a solution?
-
jjxtra about 8 yearsWhat about Windows?
-
tonisives over 7 yearsHello, I'm stuck at C:\Qt\Src\qtbase\compile.bat this fails with "C:\qt5.7-source\qtbase>jom.exe -j 4 Error: File Makefile doesn't exist." Do you know what might be the problem?
-
Alex over 7 yearsapp developer 27, make sure that the previous command in the bat file successfully done: "call C:\Qt\Src\qtbase\configure.bat -prefix %BUILD_DIR% -platform %QMAKESPEC% -confirm-license -debug-and-release -opensource -opengl desktop -no-compile-examples -icu -I C:/icu/icu/dist/include -L C:/icu/icu/dist/lib"
-
tonisives over 7 yearsthank you for your answer! Now I think got a bit further with qtbase\compile.bat. Do you have any idea what might cause the newest error "The syntax of the command is incorrect."? pastebin.com/pCLXvs22
-
Alex over 7 yearsapp developer 27, may be the make version different to mingw ot Visual Studio version, what do you use to compile? Check your make binary for make the project path and make sure that is correct.
-
tonisives over 7 yearsI never got it working. But finally found this github.com/annulen/webkit/releases/tag/qtwebkit-tp5 with which I can use newer webkit and qt 5.8.
-
user1251007 about 7 years@Muadh Programmer: The question stated that a solution for Ubuntu is wanted, so my answer is for that OS. However, the other answers address Windows. If you have questions concerning their solutions, you can comment on their answers.
-
taimoor1990 about 4 yearsCan you tell which relevant folder you pasted these files ?
-
samshers about 2 yearshow to fix this in macOS - stackoverflow.com/questions/72589559/…
-
samshers about 2 yearshow to fix this in macOS - stackoverflow.com/questions/72589559/…
-
samshers about 2 yearshow to fix this in macOS - stackoverflow.com/questions/72589559/…