Hellhound
Hellhound

Reputation: 531

How to activate c++11 support on MinGW using CMake?

I've installed latest version of MinGW/MSYS environment. Now I try to activat c++11 standard support. I've added to my cmake script:

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=gnu++0x")

If I try to build a simple test. I got the following compile failure:

error: 'shared_ptr' is not a member of 'std'

It seems to me that c++11 support is not set. If I remove the std::shared_ptr declaration from my code and try to compile some code of the chrono library it works. This confuses me. Why some c++11 libraries are supported but core elements like shared_ptr fails?

Do I need to do something extra to enable smart pointers or they are just not there?

Upvotes: 0

Views: 2247

Answers (1)

Sebastian Mach
Sebastian Mach

Reputation: 39089

You can/should (also) use -std=c++0x so as to not enable g++ extension.

Make sure to #include <memory>.

Upvotes: 2

Related Questions