QtCreator 1.3、Qt 4.6.2 和 cmake 在 windows 上的构建问题

Posted

技术标签:

【中文标题】QtCreator 1.3、Qt 4.6.2 和 cmake 在 windows 上的构建问题【英文标题】:QtCreator 1.3, Qt 4.6.2 and build problem with cmake on windows 【发布时间】:2010-02-18 23:40:33 【问题描述】:

我正在尝试从 QtCreator 构建一个 cmake 项目。当我打开项目时,我需要给 cmake 一个参数,否则不会检测到 Qt: -DQT_QMAKE_EXECUTABLE=D:/Qt/4.6.2/bin/qmake.exe

构建步骤因以下错误而停止:

Running build steps for project CollidingMice...
Starting: D:/Qt/2010.02/bin/jom.exe 
"C:\Programmi\CMake 2.8\bin\cmake.exe" -HC:\devel\SRC\collidingmice_cmake -BC:\devel\SRC\collidingmice_cmake\qtcreator-build --check-build-system CMakeFiles\Makefile.cmake 0
"C:\Programmi\CMake 2.8\bin\cmake.exe" -E cmake_progress_start C:\devel\SRC\collidingmice_cmake\qtcreator-build\CMakeFiles C:\devel\SRC\collidingmice_cmake\qtcreator-build\CMakeFiles\progress.marks
D:\Qt\2010.02\bin\jom.exe -f CMakeFiles\Makefile2 /nologo - all
D:\Qt\2010.02\bin\jom.exe -f CMakeFiles\collidingmice.dir\build.make /nologo -L CMakeFiles\collidingmice.dir\depend
"C:\Programmi\CMake 2.8\bin\cmake.exe" -E cmake_progress_report C:\devel\SRC\collidingmice_cmake\qtcreator-build\CMakeFiles 4
[ 25] Generating qrc_mice.cxx
d:\Qt\4.6.2\bin\rcc.exe -name mice -o C:/devel/SRC/collidingmice_cmake/qtcreator-build/qrc_mice.cxx C:/devel/SRC/collidingmice_cmake/mice.qrc
"C:\Programmi\CMake 2.8\bin\cmake.exe" -E cmake_depends "NMake Makefiles" C:\devel\SRC\collidingmice_cmake C:\devel\SRC\collidingmice_cmake C:\devel\SRC\collidingmice_cmake\qtcreator-build C:\devel\SRC\collidingmice_cmake\qtcreator-build C:\devel\SRC\collidingmice_cmake\qtcreator-build\CMakeFiles\collidingmice.dir\DependInfo.cmake --color=
Scanning dependencies of target collidingmice
D:\Qt\2010.02\bin\jom.exe -f CMakeFiles\collidingmice.dir\build.make /nologo -L CMakeFiles\collidingmice.dir\build
"C:\Programmi\CMake 2.8\bin\cmake.exe" -E cmake_progress_report C:\devel\SRC\collidingmice_cmake\qtcreator-build\CMakeFiles 1
[ 50] Building CXX object CMakeFiles/collidingmice.dir/main.cpp.obj
C:\PROGRA~1\MICROS~1.0\VC\bin\cl.exe     @C:\DOCUME~1\NICOLA~1\IMPOST~1\Temp\main.cpp.obj.461273.jom
jom 0.8.3 - empower your cores

command failed with exit code 2
command failed with exit code 2
command failed with exit code 2
command failed with exit code 2
Exited with code 2.
Error while building project CollidingMice
When executing build step 'Make'

我要构建的项目是 collingmice qt 示例,它是从 qt 提示符构建的。这里有 CMakeLists:

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(CollidingMice)


################################################# QT4 Handling
FIND_PACKAGE(Qt4 REQUIRED)

#this include set all the qt variable need to compile qt 
INCLUDE($QT_USE_FILE)

#Put here all headers files that need moc 
SET( Qt4_SRC
)

#Put here .ui form files
SET( Qt4_UI
)

#Put here .qrc resource files
SET( Qt4_RES mice.qrc
)

#Cmake macro 
QT4_WRAP_CPP(MOC_CPP $Qt4_SRC)
QT4_WRAP_UI(UI_CPP $Qt4_UI)
QT4_ADD_RESOURCES(RES_H $Qt4_RES)

################################################# CPack
INCLUDE(InstallRequiredSystemLibraries)

SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "My funky project")
SET(CPACK_PACKAGE_VENDOR "Me, myself, and I")
#SET(CPACK_PACKAGE_DESCRIPTION_FILE "$CMAKE_CURRENT_SOURCE_DIR/ReadMe.txt")
#SET(CPACK_RESOURCE_FILE_LICENSE "$CMAKE_CURRENT_SOURCE_DIR/Copyright.txt")
SET(CPACK_PACKAGE_VERSION_MAJOR "1")
SET(CPACK_PACKAGE_VERSION_MINOR "3")
SET(CPACK_PACKAGE_VERSION_PATCH "2")
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake $CMake_VERSION_MAJOR.$CMake_VERSION_MINOR")
IF(WIN32 AND NOT UNIX)
  # There is a bug in NSI that does not handle full unix paths properly. Make
  # sure there is at least one set of four (4) backlasshes.
  SET(CPACK_PACKAGE_ICON "$CMake_SOURCE_DIR/Utilities/Release\\\\InstallIcon.bmp")
  SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\MyExecutable.exe")
  SET(CPACK_NSIS_DISPLAY_NAME "$CPACK_PACKAGE_INSTALL_DIRECTORY My Famous Project")
  SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\www.my-project-home-page.org")
  SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\www.my-personal-home-page.com")
  SET(CPACK_NSIS_CONTACT "me@my-personal-home-page.com")
  SET(CPACK_NSIS_MODIFY_PATH ON)
ELSE(WIN32 AND NOT UNIX)
  SET(CPACK_STRIP_FILES "bin/MyExecutable")
  SET(CPACK_SOURCE_STRIP_FILES "")
ENDIF(WIN32 AND NOT UNIX)
SET(CPACK_PACKAGE_EXECUTABLES "MyExecutable" "My Executable")

INCLUDE(CPack)

################################################# General
SET(CMAKE_BUILD_TYPE Release)

SET(CMAKE_CXX_FLAGS "-Wall")

INCLUDE_DIRECTORIES( . )

SET( SRC
    main.cpp
    mouse.cpp
    $MOC_CPP
    $UI_CPP
    $RES_H
)

SET( LIB
    $QT_LIBRARIES
)

ADD_EXECUTABLE(collidingmice $SRC)
TARGET_LINK_LIBRARIES( collidingmice $LIB )

【问题讨论】:

【参考方案1】:

从 Jom 输出中并不清楚错误是什么。

尝试运行最新版本的 Qt Creator (2.0) 并将 Qt bin/ 目录添加到您的 PATH 中。

【讨论】:

以上是关于QtCreator 1.3、Qt 4.6.2 和 cmake 在 windows 上的构建问题的主要内容,如果未能解决你的问题,请参考以下文章

QtCreator 或 QtSDk

Qt学习笔记-Qtcreator的webkit和qt4.7.0的版本有关

Qt 5.6 和 QtCreator 是不是适用于 MS Visual Studio Community 2015

qt creator和qt的区别

QT4.8.7PC端安装详细教程(MinGW 4.8.2和QTCreator4.2.0)

QT4.8.7PC端安装详细教程(MinGW 4.8.2和QTCreator4.2.0)