Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

switching from Qt 5.6 to Qt 5.7 - "no member 'make_unique' in namespace std"

Tags:

c++

cmake

qt

c++14

I have a CMake Qt project which uses several c++14 features, including std::make_unique. Typically this would be handled either by:

LIST(APPEND CMAKE_CXX_FLAGS -std=c++14)

or

ADD_COMPILE_OPTIONS(-std=c++14)

I'd like to upgrade the project from version 5.6 to 5.7, but during a test build there were multiple failures with the error

no member 'make_unique' in namespace std

I've verified all the appropriate headers and compile options are in place, and ruled out any environment problems. It's definitely an issue with using Qt 5.7. Is there any workaround?

like image 717
Nicolas Holthaus Avatar asked Jul 18 '16 18:07

Nicolas Holthaus


1 Answers

So it turns out this is a known problem with CMake/Qt 5.7. Apparently, since CMake 3.1, the proper way to define which C++ standard to use in CMake is with

SET(CMAKE_CXX_STANDARD 14)

As of Qt 5.7, using any method except for CMAKE_CXX_STANDARD will result in the c++14 errors like the one mentioned in the question. Using this method cleared up all the errors for my build.

Anecdotally, the bug report is pretty interesting reading, as originally this problem was considered a release blocker, then downgraded to a known issue, and eventually (seemingly) even purged from the known issue list.

like image 112
Nicolas Holthaus Avatar answered Oct 02 '22 14:10

Nicolas Holthaus