I am using Qt creator 2.5 with CMake (2.8.7) and gcc 4.6.3 and lately I have encountered this strange error :
:-1: error: [CMakeFiles/yahtzee.dir/gamecontroller.cpp.o] Error 1
File not found
What can I do about it ? CMake is not generating this gamecontroller.cpp.o
this is my CMakeLists.txt file
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
)
And just to mention, all these files are located in directory and this is the ‘build’ directory that CMake creates :
CMakeCache.txt CMakeFiles cmake_install.cmake cpp_workshop.cbp Makefile
and the above CMakeFiles dir
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
Ok, the problem was with
Cmake‘s argument passed to gccset(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")I changed that to
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")and now it works. Surprisingly, C++11 does not work with gcc yet ?