我正在学习使用 KDE 框架的介绍性教程,但在编译时遇到了问题。代码与教程中的相同。编译器输出:
fatal error: KXmlGuiWindow: No such file or directory
我的第一个想法是我只是缺少一个包,所以我使用 apt-cache search 来搜索 kxml 并安装了 libkf5xmlgui-dev。尽管错误仍然存在。我无法在网上任何地方引用此错误。导入路径是否更改?是否需要另一个包裹?
我正在运行 Kubuntu 20.04。
我以前必须安装其他软件包来编译尚未包含 KXmlGuiWindow 的“Hello World”程序,但是当我安装它们后一切正常。
编辑:
find /usr -name KXmlGuiWindow
给了我输出/usr/include/KF5/KXmlGui/KXmlGuiWindow
。我将 Atom 用于我的代码编辑器,因此我通过运行教程中给出的命令cmake .. && make
(从项目根目录中的构建目录)从终端编译程序。
该命令的完整输出 pf 是
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Installing in the same prefix as Qt, adopting their path scheme.
-- Looking for __GLIBC__
-- Looking for __GLIBC__ - found
-- Performing Test _OFFT_IS_64BIT
-- Performing Test _OFFT_IS_64BIT - Success
-- Performing Test HAVE_DATE_TIME
-- Performing Test HAVE_DATE_TIME - Success
-- Found KF5CoreAddons: /usr/lib/x86_64-linux-gnu/cmake/KF5CoreAddons/KF5CoreAddonsConfig.cmake (found version "5.68.0")
-- Found Gettext: /usr/bin/msgmerge (found version "0.19.8.1")
-- Found KF5I18n: /usr/lib/x86_64-linux-gnu/cmake/KF5I18n/KF5I18nConfig.cmake (found version "5.68.0")
-- Found KF5WidgetsAddons: /usr/lib/x86_64-linux-gnu/cmake/KF5WidgetsAddons/KF5WidgetsAddonsConfig.cmake (found version "5.68.0")
-- Found KF5: success (found suitable version "5.68.0", minimum required is "5.2.0") found components: CoreAddons I18n WidgetsAddons
-- The following REQUIRED packages have been found:
* ECM (required version >= 1.0.0)
* Qt5Gui (required version >= 5.12.8)
* Qt5 (required version >= 5.3.0)
* Qt5Core (required version >= 5.12.0)
* KF5CoreAddons (required version >= 5.2.0)
* Gettext
* KF5I18n (required version >= 5.2.0)
* Qt5Widgets (required version >= 5.12.0)
* KF5WidgetsAddons (required version >= 5.2.0)
* KF5 (required version >= 5.2.0)
-- Configuring done
-- Generating done
-- Build files have been written to: /home/simon/Documents/Code/helloWorld/build
Scanning dependencies of target helloworld_autogen
[ 25%] Automatic MOC for target helloworld
[ 25%] Built target helloworld_autogen
Scanning dependencies of target helloworld
[ 50%] Building CXX object CMakeFiles/helloworld.dir/helloworld_autogen/mocs_compilation.cpp.o
[ 75%] Building CXX object CMakeFiles/helloworld.dir/helloWorld.cpp.o
In file included from /home/simon/Documents/Code/helloWorld/helloWorld.cpp:6:
/home/simon/Documents/Code/helloWorld/mainwindow.h:4:10: fatal error: KXmlGuiWindow: No such file or directory
4 | #include <KXmlGuiWindow>
| ^~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/helloworld.dir/build.make:76: CMakeFiles/helloworld.dir/helloWorld.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:82: CMakeFiles/helloworld.dir/all] Error 2
make: *** [Makefile:141: all] Error 2
添加标志解决了其中一个错误,即原始帖子中提到的错误。我仍然遇到其他错误,但我会先寻找现有的解决方案。