2014-04-04 59 views
-3

我想用在Ubuntu make命令來建立一個圖書館,我收到此錯誤信息:加入C++ 11支持的Makefile

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 

我明白,我需要添加C++ 11標誌某處,但我從來沒有使用過make文件,我查看了make文件,我找不到應該在哪裏添加這個。 我找不到任何提及g ++或編譯標誌或任何東西。

以下是make文件的一部分,請問我該編輯小麥嗎?

# 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 
+2

如果您需要完整的C++ 11支持,您需要超過4.8.1版的gcc版本,但以前的版本僅對此版本的標準提供部分和不完整的支持。 – user2485710

+2

通常在某處有一個'CXX_FLAGS'變量,你可以在其中添加'-std = C++ 11' –

+0

如果你仍然可以訪問它,你應該真的編輯'CMakeFiles.txt'文件,或者改變用於例如「CXXFLAGS」 'ccmake'。您發佈的文件是生成的文件。 –

回答

5

你的Makefile已經被CMake產生。

您應該在您的CMakeLists.txt中激活C++11的編譯器選項。

我做這樣的:

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

當你將生成您的解決方案,它只會正確的標誌添加到您的Makefile。

+0

它通過了這一步,但它現在正在產生一些編譯錯誤,這是正常的?我正在編譯一個庫,這應該是一個測試版本 –

+0

@ Mhd.Tahawi我不能說這是正常的或沒有看到編譯錯誤。它與C++ 11有關嗎?什麼是圖書館? –

+0

CI2CV人臉庫,謝謝你的回覆,我會深入研究併發佈一個新的問題,如果需要的話。 感謝您的回答,這是一個救星! –

2

看起來您的Makefile已經由CMake生成。因此,對於與C++ 11標準編制該行添加到的CMakeLists.txt

​​
+0

[add_definitions](http://www.cmake.org/cmake/help/v3.0/command/add_definitions.html)僅用於預處理器定義。我不知道是否有其他標誌濫用它的缺點。 – user2079303