-3

I am trying to build a library using the make command on Ubuntu, I am getting this error message:

In file included from /usr/include/c++/4.7/cstdint:35:0,
                 from /home/mohammad/face-analysis-sdk-stable/src/utils/helpers.hpp:26,
                 from /home/mohammad/face-analysis-sdk-stable/src/utils/command-line-arguments.cpp:21:
/usr/include/c++/4.7/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
make[2]: *** [src/utils/CMakeFiles/utilities.dir/command-line-arguments.cpp.o] Error 1
make[1]: *** [src/utils/CMakeFiles/utilities.dir/all] Error 2
make: *** [all] Error 2

I understand that I need to add the C++11 flag somewhere, but I have never worked with make files before, I looked through the make file and I couldn't find where should I add this. I can't find any mention for g++, or compilation flags or anything.

the following is part of the make file, would you please point to wheat should I edit ?

# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 2.8

# Default target executed when no arguments are given to make. default_target: all .PHONY : default_target

#=============================================================================
# Special targets provided by cmake.

# Disable implicit rules so canonical targets will work. .SUFFIXES:

# Remove some rules from gmake that .SUFFIXES does not remove. SUFFIXES =

.SUFFIXES: .hpux_make_needs_suffix_list

# Suppress display of executed commands. $(VERBOSE).SILENT:

# A target that is always out of date. cmake_force: .PHONY : cmake_force

#=============================================================================
# Set environment variables for the build.

# The shell in which to execute make rules. SHELL = /bin/sh

# The CMake executable. CMAKE_COMMAND = /usr/bin/cmake

# The command to remove a file. RM = /usr/bin/cmake -E remove -f

# The program to use to edit the cache. CMAKE_EDIT_COMMAND = /usr/bin/cmake-gui

# The top-level source directory on which CMake was run. CMAKE_SOURCE_DIR = /home/mohammad/face-analysis-sdk-stable

# The top-level build directory on which CMake was run. CMAKE_BINARY_DIR = /home/mohammad/face-analysis-sdk-stable/build

#=============================================================================
# Targets provided globally by CMake.

# Special rule for the target edit_cache edit_cache:    @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake cache editor..."  /usr/bin/cmake-gui
-H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) .PHONY : edit_cache

# Special rule for the target edit_cache edit_cache/fast: edit_cache .PHONY : edit_cache/fast

# Special rule for the target rebuild_cache rebuild_cache:  @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..."    /usr/bin/cmake
-H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) .PHONY : rebuild_cache

# Special rule for the target rebuild_cache rebuild_cache/fast: rebuild_cache .PHONY : rebuild_cache/fast

# The main all target all: cmake_check_build_system     $(CMAKE_COMMAND) -E cmake_progress_start /home/mohammad/face-analysis-sdk-stable/build/CMakeFiles /home/mohammad/face-analysis-sdk-stable/build/CMakeFiles/progress.marks   $(MAKE) -f CMakeFiles/Makefile2 all     $(CMAKE_COMMAND) -E cmake_progress_start /home/mohammad/face-analysis-sdk-stable/build/CMakeFiles 0 .PHONY : all

# The main clean target clean:  $(MAKE) -f CMakeFiles/Makefile2 clean .PHONY : clean

# The main clean target clean/fast: clean .PHONY : clean/fast

# Prepare targets for installation. preinstall: all     $(MAKE) -f CMakeFiles/Makefile2 preinstall .PHONY : preinstall

# Prepare targets for installation. preinstall/fast:    $(MAKE) -f CMakeFiles/Makefile2 preinstall .PHONY : preinstall/fast

# clear depends depend:     $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1 .PHONY : depend

#=============================================================================
# Target rules for targets named utilities

# Build rule for target. utilities: cmake_check_build_system    $(MAKE) -f CMakeFiles/Makefile2 utilities .PHONY : utilities

# fast build rule for target. utilities/fast:   $(MAKE) -f src/utils/CMakeFiles/utilities.dir/build.make src/utils/CMakeFiles/utilities.dir/build .PHONY : utilities/fast
Moha the almighty camel
  • 4,327
  • 4
  • 30
  • 53
  • 2
    you need a gcc release >= than 4.8.1 if you want a complete C++11 support, previous releases only offer a partial and incomplete support to this version of the standard. – user2485710 Apr 04 '14 at 13:16
  • 2
    Usually there is a `CXX_FLAGS` variable somewhere, to which you can add `-std=c++11` – user703016 Apr 04 '14 at 13:16
  • If you still have access to it you should really edit the `CMakeFiles.txt` file instead, or just change the `CXXFLAGS` used with e.g. `ccmake`. The file you posted is a generated file. – Benjamin Bannier Apr 04 '14 at 13:19

2 Answers2

5

Your Makefile has been generated by CMake.

You should activate the compiler options for C++11 in your CMakeLists.txt.

I'm doing it like this :

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

When you will generate your solution, it will simply add the correct flags to your Makefile.

Pierre Fourgeaud
  • 14,290
  • 1
  • 38
  • 62
  • it passed that step, but it is now generating some compilation errors, is that normal ? I am compiling a library and this is supposed to be a tested release version – Moha the almighty camel Apr 04 '14 at 13:38
  • @Mhd.Tahawi I can't say it is normal or not without seeing the compilation errors. Is it related to c++11 ? What is the library ? – Pierre Fourgeaud Apr 04 '14 at 13:41
  • CI2CV face library, thank you for your respone, I will dig into it and post a new question if needed. thanks agian for your answer, it is a life saver ! – Moha the almighty camel Apr 04 '14 at 13:44
  • @Mhd.Tahawi You are welcome :) I think it is the best solution. First try to see if you can fix those errors and if you are stuck, post a new question. – Pierre Fourgeaud Apr 04 '14 at 13:45
  • I would use `set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")` to avoid overwriting flags that may have been set already. And I would use the system default standard library unless there's a specific need to use another. – eerorika Apr 04 '14 at 13:50
  • @user2079303 You are right. I made the changes in my post. Thanks for the comment. – Pierre Fourgeaud Apr 04 '14 at 13:52
2

Looks like your Makefile has been generated by CMake. So for compiling with C++11 standard add this line to CMakeLists.txt

add_definitions(-std=c++0x)
totoro
  • 161
  • 2
  • 7
  • [add_definitions](http://www.cmake.org/cmake/help/v3.0/command/add_definitions.html) is intended only for preprocessor definitions. I don't know if there are downsides for misusing it for other flags though. – eerorika Apr 04 '14 at 13:37