Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. C++ 14 error with Qt 5.6.1
Forum Updated to NodeBB v4.3 + New Features

C++ 14 error with Qt 5.6.1

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
16 Posts 3 Posters 5.4k Views 2 Watching
  • 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

    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

    ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #2

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

    1 Reply Last reply
    0
    • R Offline
      R Offline
      Rubin Stove
      wrote on last edited by
      #3

      @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
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #4

        What's your compiler / compiler version?

        1 Reply Last reply
        0
        • R Offline
          R Offline
          Rubin Stove
          wrote on last edited by
          #5

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

          kshegunovK ? 2 Replies Last reply
          0
          • R Rubin Stove

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

            kshegunovK Offline
            kshegunovK Offline
            kshegunov
            Moderators
            wrote on last edited by
            #6

            @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
            0
            • R Rubin Stove

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

              ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #7

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

              kshegunovK 1 Reply Last reply
              1
              • ? A Former User

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

                kshegunovK Offline
                kshegunovK Offline
                kshegunov
                Moderators
                wrote on last edited by
                #8

                @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
                0
                • R Offline
                  R Offline
                  Rubin Stove
                  wrote on last edited by Rubin Stove
                  #9

                  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
                  0
                  • R Offline
                    R Offline
                    Rubin Stove
                    wrote on last edited by Rubin Stove
                    #10

                    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
                    0
                    • R 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 ?

                      ? Offline
                      ? Offline
                      A Former User
                      wrote on last edited by
                      #11

                      @Rubin-Stove said:

                      Did you compile that code from Qt creator ?

                      yes

                      1 Reply Last reply
                      0
                      • R Offline
                        R Offline
                        Rubin Stove
                        wrote on last edited by
                        #12

                        @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
                        0
                        • R Rubin Stove

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

                          ? Offline
                          ? Offline
                          A Former User
                          wrote on last edited by
                          #13

                          @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
                          0
                          • R Offline
                            R Offline
                            Rubin Stove
                            wrote on last edited by
                            #14

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

                            1 Reply Last reply
                            0
                            • ? Offline
                              ? Offline
                              A Former User
                              wrote on last edited by
                              #15

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

                              1 Reply Last reply
                              0
                              • R Offline
                                R Offline
                                Rubin Stove
                                wrote on last edited by
                                #16

                                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
                                0

                                • Login

                                • Login or register to search.
                                • First post
                                  Last post
                                0
                                • Categories
                                • Recent
                                • Tags
                                • Popular
                                • Users
                                • Groups
                                • Search
                                • Get Qt Extensions
                                • Unsolved