I am trying to use <chrono> in ubuntu 14.04 with g++/gcc 4.8.2 and I cannot see the std::chrono namespace. My development enviroment is eclipse luna, using cmake 2.8.2 (all from repository in 14.04).
I can include the header, which it sees in /usr/include/c++/4.8/, but I get build errors saying it cannot find std::chrono. I am trying to use the high resolution clock for a stopwatch class to calculate execution time of some code.
I saw some preprocessor macros in the chrono header but they all should be fine if I am linking against c++11. Any ideas?
Thank you guys for your replies. I already have -std=c++11 as a linker flag. I use many lambda functions throughout in other classes within the program.
Using CMake, this is what I have:
...
# check available compiler versions
# throw error if c++11 is not available
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif(COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()
# link extra link libraries
# this is global for every project...
link_libraries(-lrt -lm -lpthread)