C++ 14 error with Qt 5.6.1
-
I using the new Qt Creator 4.0.1 based on Qt 5.6.1. For android build I am pointing to ndk r12 which is the latest.
But for using shared_timed_mutex, I keep getting the following error:
"This file requires compiler and library support for the forthcoming
ISO C++ 2014 standard. This support is currently experimental, and must be
enabled with the -std=c++1y or -std=gnu++1y compiler options."I understand that this not really a Qt specific problem. But rather gcc compiler related problem. But this problem did not occur with the previous version on Qt that is Qt Creator 3.6.0 based on Qt 5.5.1. The error is popping up only with the new update 5.6.1. Any suggestions to help resolve the problem is appreciated. Thanks in advance
-
@Rubin-Stove Hi! You can enable C++14 support by adding
CONFIG += c++14
to your *.pro file. -
@Wieland said:
CONFIG += c++14
Hi, CONFIG += c++14 ia enabled in .pro file. It still complains about the same error
-
What's your compiler / compiler version?
-
I am using android ndk r12 for building this code. I think it has gcc 4.8
-
gcc 4.8
https://gcc.gnu.org/projects/cxx-status.html
Some (or rather most) c++14 features will not be available for that compiler, or may be partially implemented.
-
@Rubin-Stove Yepp, @kshegunov is right. I just tested the following code...
#include <shared_mutex> #include <mutex> #include <iostream> class R { mutable std::shared_timed_mutex mut; public: R& operator=(const R& other) { std::unique_lock<std::shared_timed_mutex> lhs(mut, std::defer_lock); std::shared_lock<std::shared_timed_mutex> rhs(other.mut, std::defer_lock); std::lock(lhs, rhs); return *this; } }; int main() { R r; std::cout << "Hello" << std::endl; return 0; }
... on Linux and the lowest possible compiler version it works with is GCC 4.9 with C++14 features explicitly enabled.
-
-
Looks like experimental support of C++14 in gcc is causing me this error. Somehow, I need to upgrade gcc in ndk r12 to 4.9 or above
-
Really strange. If you check toolchains folder of ndk r12, it looks to be on gcc 4.9
https://developer.android.com/ndk/downloads/index.html
https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/Still it complains of c++14. Looks like the c++14 config enabled in .pro file is not really getting carried into gcc when compilation is happening.
@Wieland . Did you compile that code from Qt creator ? -
-
@Wieland Can you pls share your .pro file please ?
Also, can you please confirm that you are using nkd r12 as it is downloaded from here ?
https://developer.android.com/ndk/downloads/index.htmlYou android tab of build & run settings in qt creator is pointing to android ndk r 12 ?
-
@Rubin-Stove Arg, sry, there is a misunderstanding: I did not compile with the Android NDK but only the code I posted above for Linux x86_64 because I wanted to see which GCC version can handle shared mutex correctly.
-
@Wieland . Nevermind dude. I now fixed the error with your help. Thanks a lot man
-
Glad you solved it! Could you please post the solution? Might be useful to other users, too :-)
-
My code had another mistake which was causing the issue. I fixed it along with the config setting of C++14 in .pro file. Apart from this, following info would certainly hep others facing exactly the same issue.
Install clang toolchain as a stand alone binary. More info at
https://developer.android.com/ndk/guides/standalone_toolchain.html#wwcAlso, Gcc is about to phase out in r13 of ndk. So that might fix these kind of problems for good
https://news.ycombinator.com/item?id=10772826