Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Unsolved C++ 14 error with Qt 5.6.1

    Mobile and Embedded
    3
    16
    4629
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R
      Rubin Stove last edited by

      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

      ? 1 Reply Last reply Reply Quote 0
      • ?
        A Former User @Rubin Stove last edited by

        @Rubin-Stove Hi! You can enable C++14 support by adding CONFIG += c++14 to your *.pro file.

        1 Reply Last reply Reply Quote 0
        • R
          Rubin Stove last edited by

          @Wieland said:

          CONFIG += c++14

          Hi, CONFIG += c++14 ia enabled in .pro file. It still complains about the same error

          1 Reply Last reply Reply Quote 0
          • ?
            A Former User last edited by

            What's your compiler / compiler version?

            1 Reply Last reply Reply Quote 0
            • R
              Rubin Stove last edited by

              I am using android ndk r12 for building this code. I think it has gcc 4.8

              kshegunov ? 2 Replies Last reply Reply Quote 0
              • kshegunov
                kshegunov Moderators @Rubin Stove last edited by

                @Rubin-Stove

                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.

                Read and abide by the Qt Code of Conduct

                1 Reply Last reply Reply Quote 0
                • ?
                  A Former User @Rubin Stove last edited by

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

                  kshegunov 1 Reply Last reply Reply Quote 1
                  • kshegunov
                    kshegunov Moderators @Guest last edited by

                    @Wieland said:

                    Yepp, @kshegunov is right.

                    Rather the guys writing gcc are right. ;)

                    Read and abide by the Qt Code of Conduct

                    1 Reply Last reply Reply Quote 0
                    • R
                      Rubin Stove last edited by Rubin Stove

                      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

                      1 Reply Last reply Reply Quote 0
                      • R
                        Rubin Stove last edited by Rubin Stove

                        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 ?

                        ? 1 Reply Last reply Reply Quote 0
                        • ?
                          A Former User @Rubin Stove last edited by

                          @Rubin-Stove said:

                          Did you compile that code from Qt creator ?

                          yes

                          1 Reply Last reply Reply Quote 0
                          • R
                            Rubin Stove last edited by

                            @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.html

                            You android tab of build & run settings in qt creator is pointing to android ndk r 12 ?

                            ? 1 Reply Last reply Reply Quote 0
                            • ?
                              A Former User @Rubin Stove last edited by

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

                              1 Reply Last reply Reply Quote 0
                              • R
                                Rubin Stove last edited by

                                @Wieland . Nevermind dude. I now fixed the error with your help. Thanks a lot man

                                1 Reply Last reply Reply Quote 0
                                • ?
                                  A Former User last edited by

                                  Glad you solved it! Could you please post the solution? Might be useful to other users, too :-)

                                  1 Reply Last reply Reply Quote 0
                                  • R
                                    Rubin Stove last edited by

                                    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#wwc

                                    Also, 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

                                    1 Reply Last reply Reply Quote 0
                                    • First post
                                      Last post