CMake编译Kate源码时QWidgetAction未声明错误求助
Hey Pablo, sorry to hear you're stuck on compiling Kate—let's get this sorted out. The error you're seeing ('QWidgetAction' was not declared in this scope) points to a missing link to Qt's Widgets module, even though you've installed most dependencies. Here's how to fix it:
1. Simplify Your CMake Command
Your current CMake command has manual Qt path overrides (TARGET_include_directories, Qt5_INCLUDE_DIRS, etc.) that are likely interfering with CMake's automatic Qt module detection. CMake is designed to find Qt on its own when the right packages are installed, so strip those out. Use this instead:
#! /bin/bash cmake \ -D CMAKE_BUILD_TYPE=RelWithDebInfo \ -D CMAKE_INSTALL_PREFIX=~/kde/usr \ -D KDE_INSTALL_USE_QT_SYS_PATHS:BOOL=ON \ ../kate/
2. Verify the QtWidgets Development Package is Installed
While qtbase5-dev should include QtWidgets, it's worth double-checking that the specific widgets dev package is present (sometimes dependencies can get messed up):
sudo apt install libqt5widgets5-dev
3. Clean Up and Rebuild from Scratch
Old build cache can cause weird lingering issues. Wipe your build directory and start fresh:
# Replace "build" with your actual build directory name if different rm -rf build/ mkdir build && cd build # Run the simplified CMake command above make make install
4. Check for Missing Include (If the Above Fails)
In rare cases, the katesqlview.cpp file might be missing the necessary include for QWidgetAction. Open /home/pablo/kde/kate/addons/katesql/katesqlview.cpp and add this line at the top with the other includes:
#include <QWidgetAction>
Then re-run make.
As a side note: If your original Kate issue was just the missing ~/.config/kate folder, you could also try creating a new one (Kate will generate default configs on launch) or copying the default config from /usr/share/kate/ to your home directory, but since you're set on compiling, focusing on the above steps should get you past the error.
内容的提问来源于stack exchange,提问作者Pablo

