cmake build_error ai_generated true

CMake 错误:AUTOGEN:未找到目标 'myapp' 的有效 Qt 'uic' 可执行文件

CMake Error: AUTOGEN: No valid Qt 'uic' executable found for target 'myapp'

ID: cmake/autogen-uic-not-found

其他格式: JSON · Markdown 中文 · English
82%修复率
85%置信度
1证据数
2024-03-15首次发现

版本兼容性

版本状态引入弃用备注
Qt5 5.15.2 active
Qt6 6.5.0 active
CMake 3.28 active
CMake 3.29 active

根因分析

Qt5/Qt6 的 AUTOMOC/AUTOUIC/AUTORCC 需要 uic 可执行文件在 PATH 中或通过 Qt5_DIR/Qt6_DIR 指定,但 uic 缺失或版本不匹配。

English

Qt5/Qt6 AUTOMOC/AUTOUIC/AUTORCC requires uic binary in PATH or via Qt5_DIR/Qt6_DIR, but it's missing or version mismatched.

generic

解决方案

  1. 安装 Qt 开发工具:sudo apt install qtbase5-dev qtbase5-dev-tools(或 qttools5-dev 以获取 uic)。然后重新配置。
  2. 在 CMake 中显式设置 uic 路径:在 find_package(Qt5) 之前设置 set(QT_UIC_EXECUTABLE /usr/lib/qt5/bin/uic)。

无效尝试

常见但无效的做法:

  1. Reinstall Qt and set CMAKE_PREFIX_PATH to the install root 30% 失败

    If only the library is installed without the development tools (uic, moc), find_package(Qt5) might succeed but uic is still missing.

  2. Set CMAKE_AUTOUIC OFF and manually run uic 40% 失败

    Turning off AUTOUIC bypasses the error but leaves UI compilation unhandled, causing linker errors later.