编译Kompare后运行报错:无法加载KompareNavigationPart求助
Let's break down what's happening here: the errors about missing kompareui.rc and the Kompare/ViewPart service type mean your built Kompare binary can't find the necessary resource files and service descriptors that KDE frameworks rely on. These files aren't automatically picked up from your build directory unless you tell the system where to look, or you install the app properly. Here's how to fix this:
1. Install Kompare After Building (Recommended)
KDE applications expect their resource files (like .rc UI definitions) and .desktop service files to live in standard system or user-specific KDE directories. The easiest way to make these accessible is to install your built copy:
- If you ran
cmakewithout a custom prefix, run:sudo make install - For a user-local install (no sudo needed, files go to
~/.local), re-run cmake with the prefix first:cd your-build-directory cmake -DCMAKE_INSTALL_PREFIX=~/.local .. make && make install
After installation, running kompare directly should work without issues, since all necessary files are now in paths KDE frameworks scan by default.
2. Run Without Installing (Temporary Testing)
If you don't want to install the app and just want to test your build, you need to set environment variables to point KDE frameworks to your build directory's resources:
- From your Kompare build directory, set these variables:
export KDEDIRS=$PWD export XDG_DATA_DIRS=$PWD/share:$XDG_DATA_DIRS - Update KDE's service cache to recognize the new service files:
kbuildsycoca5 - Now run your built binary:
./kompare
This tells KDE's KService and KXmlGui frameworks to look in your build directory for the missing .rc and .desktop files instead of only checking system paths.
Quick Check to Rule Out Build Issues
Before trying the above, double-check your build logs for any warnings about missing dependencies (like KXmlGui or KService) or failed file generation. If cmake couldn't find some required KDE frameworks, that might lead to missing resource files in the first place.
内容的提问来源于stack exchange,提问作者saga

