我不明白 我在qt5 cmake指南之後做了一個小例子。 這是一個最小的例子。qt5 cmake no automoc
cmake_minimum_required(VERSION 2.8.11)
project(basic_qt_gui)
set(CMAKE_PREFIX_PATH "/opt/qt5_5_0/5.5/gcc_64")
# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)
# Find the QtWidgets library
find_package(Qt5Widgets)
find_package(Qt5Core)
find_package(Qt5Gui)
set(BASIC_QT_GUI_HEADERS mainwindow.h)
set(BASIC_QT_GUI_SOURCES main.cpp
mainwindow.cpp)
# Tell CMake to create the helloworld executable
add_executable(basic_qt_gui ${BASIC_QT_GUI_HEADERS} ${BASIC_QT_GUI_SOURCES})
# Use the Widgets module from Qt 5.
target_link_libraries(basic_qt_gui Qt5::Widgets)
化妝後,我總是得到這個錯誤
[ 25%] Automoc for target basic_qt_gui
Generating moc_mainwindow.cpp
[ 25%] Built target basic_qt_gui_automoc
Scanning dependencies of target basic_qt_gui
[ 50%] Building CXX object CMakeFiles/basic_qt_gui.dir/main.cpp.o
[ 75%] Building CXX object CMakeFiles/basic_qt_gui.dir/mainwindow.cpp.o
/home/gatherer/Dokumente/gitHubProjekte/basic_qt_gui/mainwindow.cpp:2:27: fatal error: ui_mainwindow.h: No such file or directory
#include "ui_mainwindow.h"
^
compilation terminated.
make[2]: *** [CMakeFiles/basic_qt_gui.dir/mainwindow.cpp.o] Error 1
make[1]: *** [CMakeFiles/basic_qt_gui.dir/all] Error 2
make: *** [all] Error 2
我看了看周圍很多,但我找不到一個錯誤。 我用CMake的2.8.12和qt5.5.0
編輯:解..安裝cmake的3.2.2,並添加
set(CMAKE_AUTOUIC ON)
這解決了問題。 2.8.12是一個真正有線的版本
是ui_mainwindow.h和mainwindow.h。這是汽車欺騙還是錯誤? – usr1234567
它是正確的,它應該工作的方式... – gatherer
我使用的指南...沒有什麼難以理解的http://doc.qt.io/qt-5/cmake-manual.html ..所以它更多有線 – gatherer