C++ 项目错误:QT 中的未知模块:webkitwidgets
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18699403/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Project ERROR: Unknown module(s) in QT: webkitwidgets
提问by user1251007
I am porting code from qt4 to qt5. I added the following line to my .pro
file, as suggested:
我正在将代码从 qt4 移植到 qt5。我按照建议将以下行添加到我的.pro
文件中:
QT += webkitwidgets
However, when I run qmake
, I get the this error:
但是,当我运行时qmake
,出现此错误:
Project ERROR: Unknown module(s) in QT: webkitwidgets
I am developing on Ubuntu 12.04 LTS and installed Qt as described.
我开发在Ubuntu 12.04 LTS,并安装Qt的描述。
回答by user1251007
You need to install the webkitwidgets library.
您需要安装 webkitwidgets 库。
On Ubuntu, try this in a terminal:
在 Ubuntu 上,在终端中试试这个:
sudo apt-get install libqt5webkit5-dev
回答by Alex
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.
如果您需要为 Qt 5.7 安装 webkit* Windows 库,您应该手动编译它,因为在新版本中 webkit (WebView?) 被 WebEngine 取代。
Read about Qt 5.7 release (comments): http://blog.qt.io/blog/2016/06/16/qt-5-7-released/
阅读 Qt 5.7 版本(评论):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/
1)下载Qt 5.7.0源码: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
2)下载所需工具:ActiveState Perl(二进制)、Python(二进制)、Ruby(二进制)、GnuWin Bison(二进制)、GPref(二进制)、Grep(二进制)、WinFlex、LibIconv、make(二进制)、sqlite(源代码) !), ICU (source), windows msys (binary) (unix like shell with the tools), mingw-w64 (bin+dev) 用于使用 QtWebKit 构建 Qt,见链接: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:
3) 将ICU源码下载到C:\icu\icu后。通过打开开始窗口菜单(应下载并安装 msys)并搜索或使用快速搜索,打开 msys QT mingw 控制台外壳。在打开的控制台中启动配置脚本,然后编译安装:
$ cd C:\icu\icu\source
$ ./runConfigureICU
$ set PATH=%PATH%;C:\msys\1.0\bin\
$ make.exe
$ make.exe install
$ cd C:\icu\icu\source
$ ./runConfigureICU
$ set PATH=%PATH%;C:\msys\1.0\bin\
$make.exe
$ make.exe 安装
4) Build Qt with(!) ICU support (set "-icu" to configure) see compile script below. Change PATH to your environment.
4)使用(!)ICU支持构建Qt(设置“-icu”进行配置)请参阅下面的编译脚本。将 PATH 更改为您的环境。
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\5.7.0 - 在此处下载 Qt 5.7.0 的二进制版本
- C:\Qt\5.7.0n - 5.7.0 新(编译)版本的目录(只需制作目录)
- C:\Qt\Src - 在此处下载 Qt 5.7.0 的源代码
C:\Qt\Src\qtbase\compile.bat
C:\Qt\Src\qtbase\compile.bat
set INCLUDE=C:\icu\icu\dist\include
set LIB=C:\icu\icu\dist\lib
set QTDIR=C:\Qt.7.0n
set PATH=%PATH%;C:\Qt\Qt5.7.0.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:
在 Windows Power Shell 中运行示例中的命令:
$ cd C:\Qt\Src\qtbase
$ ./compile.bat
$ cd C:\Qt\Src\qtbase
$ ./compile.bat
After pass through compile use it to install files in the BUILD_DIR (install Qt files):
通过编译后使用它来安装 BUILD_DIR 中的文件(安装 Qt 文件):
$ C:\mingw-w64\i686-1\mingw32\bin\mingw32-make.exe install
$ C:\mingw-w64\i686-1\mingw32\bin\mingw32-make.exe 安装
Qt should start to install
Qt应该开始安装
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.
5) 将Qtwebkit 源码下载到C:\Qt\Src\qtwebkit。使用下面的编译脚本使用新的 Qt 5.7.0 版本编译 qtwebkit,文件位于 C:\Qt\5.7.0n 和 ICU。
C:\Qt\Src\qtwebkit\Tools\Scripts\compile.bat
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:
编译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
$ 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 安装
It should be possible to compile your application with the qtwebkit after successfull compile and install.
成功编译和安装后,应该可以使用 qtwebkit 编译您的应用程序。
BUILD QT FOR STATIC
为静态构建 QT
Edit file C:\Qt\Src\qtbase\compile.bat and pass through build.
编辑文件 C:\Qt\Src\qtbase\compile.bat 并通过 build.bat
...
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"
1) 在构建 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.
检查您的 Qt 5.7.0n 是否使用 ICU 构建。IT 还可以在 qtwebkit 中配置时通知您“需要 ICU”。
2) flex: unknown flag '-'. For usage, try
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).
在这种情况下,您应该使用正确版本的 Flex,即“win_flex”。您应该重命名文件以使用 win_flex 而不仅仅是 flex(和野牛)。
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.
1) 将 C:\Program Files (x86)\GnuWin32\bin\flex.exe 重命名为一些未使用的名称。
2) 将 C:\Program Files (x86)\GnuWin32\bin\bison.exe 重命名为一些未使用的名称。
3) 将 C:\winflex\win_bison.exe 重命名为 bison.exe。
3) While build qtwebkit: "fatal error: sqlite3.h: No such file or directory"
3) 在构建 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:
编辑文件 C:\Qt\Src\qtwebkit\Tools\Scripts\compile.bat 并检查 sqlite 的正确路径:
set SQLITE3SRCDIR=C:\(path to some SQLITE .h/source files)
4) skipping incompatible ... when searching for ...
4) skipping incompatible ... when searching for ...
You should download right library arch (32bit or 64bit)
您应该下载正确的库 arch(32 位或 64 位)
5) View.cpp ... undefined reference to WKPageCanGoBack
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.
通过某些测试或 MiniBrowser 时可能会发生。您可以在文件中搜索“UIProcess/API/qt”和“MiniBroswer”并将其从 Makefile 和其他一些文件中删除,然后再次开始构建。
LINKS
链接
Build Qt5: https://wiki.qt.io/Building_Qt_5_from_GitQt WebKit build
like how to: https://trac.webkit.org/wiki/BuildingQtOnWindowsICU
build with GNU: https://wiki.qt.io/Compiling-ICU-with-MinGW
构建 Qt5:https://wiki.qt.io/Building_Qt_5_from_Git Qt WebKit 构建
喜欢如何:https: //trac.webkit.org/wiki/BuildingQtOnWindowsICU
使用 GNU 构建:https: //wiki.qt.io/Compiling-ICU-with-MinGW
回答by Nightingale7
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".
Alex 引用的社区构建仅在 Qt 5.9 之前可用。如果您想使用较新的 Qt5(当前版本为 5.11),则另一个选择是将“QtWebKit”移植到“QtWebEngine”。
回答by JDavis
I got it to work by copying the webkit and webkitwidgets pri files from a previous installation, 5.5.
我通过从以前的安装 5.5 复制 webkit 和 webkitwidgets pri 文件来使其工作。
~/Qt/5.5/clang_64/mkspecs/modules/
~/Qt/5.5/clang_64/mkspecs/modules/
回答by tonisives
For windows, I just downloaded https://github.com/annulen/webkit/releases/tag/qtwebkit-tp5and 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!
对于 Windows,我刚刚下载了https://github.com/annulen/webkit/releases/tag/qtwebkit-tp5并将文件夹复制到相关的 Qt 安装文件夹。现在我可以将 MinGW Qt5.8 与最新的 webkit 一起使用。感谢 Konstantin 和这个项目的所有贡献者!
Only one thing to note - I needed to use the release configuration in Qt.
只有一件事需要注意 - 我需要在 Qt 中使用发布配置。
回答by G. Adnane
What works for me is the combination of two answers, I used what @user1251007 suggested + this command
对我有用的是两个答案的组合,我使用了@user1251007 建议的 + 这个命令
sudo apt-get install libqt5websockets5-dev
find this command line here : link to the stackoverflow response
在此处找到此命令行:链接到 stackoverflow 响应