Вопрос

I have a project I've been working for some time, always in debug. Today I tried building a release, and it fails to compile throwing some very weird errors. While the debug compiles without any warnings, release throws:

/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.

Both CMake builds have c++11 enabled:

set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -std=gnu++11 -Wall -g")
set(CMAKE_CSS_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -std=gnu++11 -Wall")

How can I track What is causing the compilation errors in Release?

EDIT I am using Cmake 2.8 and have tried to compile with gcc-4.6.3 and 4.7.2 and both have the same problem.

EDIT#2 Problem persists when using -std=c++0x instead of c++11.

EDIT#3 Downgrading to g++4.6 did not do much help. The error now simply changed to:

/usr/include/c++/4.6/bits/c++0x_warning.h:32:2:etc...

EDIT#4 I have removed <thread> which first caused problems. Then it was <mutex> and <atomic>. Now it is any piece of code that uses std::shared_ptr<Blah>. It seems to me as if Release does not want to compile with C++11 at all. Is this on purpose?

Это было полезно?

Решение

I bet the problem comes from this line:

set(CMAKE_CSS_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -std=gnu++11 -Wall")

Look, you set the variable CMAKE_CSS_FLAGS_RELEASE. Chances are you just wanted to set the variable CMAKE_CXX_FLAGS_RELEASE instead. That would explain why your c++11 is not enabled in release mode.

Другие советы

I have fixed the problem by simply removing the CXX_FLAG, and using CMake's add definitions:

add_definitions("-std=gnu++11")

I do not know why this made it work, and why debug worked but release didn't, but it made a big difference.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top