cmake
build_error
ai_generated
true
CMake Error: AUTOGEN: No valid Qt 'uic' executable found for target 'myapp'
ID: cmake/autogen-uic-not-found
82%Fix Rate
85%Confidence
1Evidence
2024-03-15First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| Qt5 5.15.2 | active | — | — | — |
| Qt6 6.5.0 | active | — | — | — |
| CMake 3.28 | active | — | — | — |
| CMake 3.29 | active | — | — | — |
Root Cause
Qt5/Qt6 AUTOMOC/AUTOUIC/AUTORCC requires uic binary in PATH or via Qt5_DIR/Qt6_DIR, but it's missing or version mismatched.
generic中文
Qt5/Qt6 的 AUTOMOC/AUTOUIC/AUTORCC 需要 uic 可执行文件在 PATH 中或通过 Qt5_DIR/Qt6_DIR 指定,但 uic 缺失或版本不匹配。
Workarounds
-
85% success Install Qt development tools: sudo apt install qtbase5-dev qtbase5-dev-tools (or qttools5-dev for uic). Then reconfigure.
Install Qt development tools: sudo apt install qtbase5-dev qtbase5-dev-tools (or qttools5-dev for uic). Then reconfigure.
-
75% success Explicitly set the uic path in CMake: set(QT_UIC_EXECUTABLE /usr/lib/qt5/bin/uic) before find_package(Qt5).
Explicitly set the uic path in CMake: set(QT_UIC_EXECUTABLE /usr/lib/qt5/bin/uic) before find_package(Qt5).
中文步骤
安装 Qt 开发工具:sudo apt install qtbase5-dev qtbase5-dev-tools(或 qttools5-dev 以获取 uic)。然后重新配置。
在 CMake 中显式设置 uic 路径:在 find_package(Qt5) 之前设置 set(QT_UIC_EXECUTABLE /usr/lib/qt5/bin/uic)。
Dead Ends
Common approaches that don't work:
-
Reinstall Qt and set CMAKE_PREFIX_PATH to the install root
30% fail
If only the library is installed without the development tools (uic, moc), find_package(Qt5) might succeed but uic is still missing.
-
Set CMAKE_AUTOUIC OFF and manually run uic
40% fail
Turning off AUTOUIC bypasses the error but leaves UI compilation unhandled, causing linker errors later.