Qt creator -1:错误:[CMakeFiles / yahtzee.dir / gamecontroller.cpp.o]错误1:找不到文件

时间:2012-07-19 08:05:32

标签: gcc cmake qt-creator file-not-found

我正在使用Qt creator 2.5和CMake(2.8.7)以及gcc 4.6.3,最近我遇到了这个奇怪的错误:

  

: - 1:错误:[CMakeFiles / yahtzee.dir / gamecontroller.cpp.o]错误1   找不到文件

我该怎么办? CMake没有生成此gamecontroller.cpp.o

这是我的CMakeLists.txt文件

project(cpp_workshop)
cmake_minimum_required(VERSION 2.6)

# Set default compile flags for GCC
if(CMAKE_COMPILER_IS_GNUCXX)
    message(STATUS "GCC detected, adding compile flags")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pedantic -Wall -Wextra -Werror")
else()
    message(STATUS "GCC not detected, probably running Windows")
endif(CMAKE_COMPILER_IS_GNUCXX)


#add_definitions("-Wall -Werror")
ADD_DEFINITIONS("-Wno-unused-parameter")

add_executable(yahtzee #name of the executable
gamecontroller.h gamecontroller.cpp
player.h player.cpp
game.h game.cpp
dice.h dice.cpp
strategy.cpp strategy.h
istrategy.h
game_rules.h
main singleton 
)

就是说,所有这些文件都位于目录中,这是CMake创建的“build”目录:

CMakeCache.txt  CMakeFiles  cmake_install.cmake  cpp_workshop.cbp  Makefile

以及上面的CMakeFiles目录

CMakeCCompiler.cmake               CMakeDirectoryInformation.cmake  CompilerIdCXX   TargetDirectories.txt
cmake.check_cache                  CMakeOutput.log                  Makefile2       yahtzee.dir
CMakeCXXCompiler.cmake             CMakeSystem.cmake                Makefile.cmake
CMakeDetermineCompilerABI_C.bin    CMakeTmp                         Progress
CMakeDetermineCompilerABI_CXX.bin  CompilerIdC                      progress.marks

1 个答案:

答案 0 :(得分:1)

好的,问题是将Cmake的参数传递给gcc

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

我把它改为

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")

现在它有效。令人惊讶的是,C ++ 11还不适用于gcc吗?