Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. How to install C17 on Linux and setup QT Creator?
Forum Updated to NodeBB v4.3 + New Features

How to install C17 on Linux and setup QT Creator?

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
13 Posts 3 Posters 2.1k Views 1 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.
  • N Offline
    N Offline
    Natural_Bugger
    wrote on 15 Aug 2020, 18:12 last edited by Natural_Bugger
    #1

    https://gcc.godbolt.org/z/WXKLCk

         #include <iostream>
         #include <iterator>
    
        int arr[3][3];
    
         auto it=begin(arr);
         cout<<"Hello"<<*(*it+1)<<endl;
    

    errors;

    error: no matching function for call to ‘begin(char [n][n])’
       63 |         auto it=begin(grid);
          |                           ^
    error: no matching function for call to 'begin'
    

    typing "std::" ... begin() ... doesn't show up in the context menu.
    i have the same headers files, what am i doing wrong?

    J 1 Reply Last reply 15 Aug 2020, 19:28
    0
    • N Natural_Bugger
      15 Aug 2020, 18:12

      https://gcc.godbolt.org/z/WXKLCk

           #include <iostream>
           #include <iterator>
      
          int arr[3][3];
      
           auto it=begin(arr);
           cout<<"Hello"<<*(*it+1)<<endl;
      

      errors;

      error: no matching function for call to ‘begin(char [n][n])’
         63 |         auto it=begin(grid);
            |                           ^
      error: no matching function for call to 'begin'
      

      typing "std::" ... begin() ... doesn't show up in the context menu.
      i have the same headers files, what am i doing wrong?

      J Offline
      J Offline
      J.Hilk
      Moderators
      wrote on 15 Aug 2020, 19:28 last edited by
      #2

      @Natural_Bugger
      IIRC std::begin requieres at least c++11 ? (Or 17)
      To what did. you set the Compiler ?


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      N 1 Reply Last reply 16 Aug 2020, 06:55
      2
      • J J.Hilk
        15 Aug 2020, 19:28

        @Natural_Bugger
        IIRC std::begin requieres at least c++11 ? (Or 17)
        To what did. you set the Compiler ?

        N Offline
        N Offline
        Natural_Bugger
        wrote on 16 Aug 2020, 06:55 last edited by Natural_Bugger
        #3

        @J-Hilk

        hi, i have QT version 5.9.9 GCC, as it came out of the box.
        compiler C++ GCC (C++, x86, 64bit in /usr/bin)

        i downloaded c17
        https://askubuntu.com/questions/1113974/using-c17-with-clang-on-ubuntu-16-04

        all good and resided in "/usr/include/c++/9"
        what to do next?

        i found some info:
        https://amirkoblog.wordpress.com/2018/08/14/creating-c17-enabled-qt-projects/
        but ... that applies to Qt 5.11.

        J 1 Reply Last reply 16 Aug 2020, 07:05
        0
        • N Natural_Bugger
          16 Aug 2020, 06:55

          @J-Hilk

          hi, i have QT version 5.9.9 GCC, as it came out of the box.
          compiler C++ GCC (C++, x86, 64bit in /usr/bin)

          i downloaded c17
          https://askubuntu.com/questions/1113974/using-c17-with-clang-on-ubuntu-16-04

          all good and resided in "/usr/include/c++/9"
          what to do next?

          i found some info:
          https://amirkoblog.wordpress.com/2018/08/14/creating-c17-enabled-qt-projects/
          but ... that applies to Qt 5.11.

          J Offline
          J Offline
          JonB
          wrote on 16 Aug 2020, 07:05 last edited by
          #4

          @Natural_Bugger
          Did you try applying the principles shown in that last link to your Qt 5.9.9 situation?

          N 2 Replies Last reply 16 Aug 2020, 07:12
          0
          • J JonB
            16 Aug 2020, 07:05

            @Natural_Bugger
            Did you try applying the principles shown in that last link to your Qt 5.9.9 situation?

            N Offline
            N Offline
            Natural_Bugger
            wrote on 16 Aug 2020, 07:12 last edited by
            #5

            @JonB

            that's what I'm trying to figuring out.
            that article applies to windows.

            i'm not sure what to do now

            J 1 Reply Last reply 16 Aug 2020, 08:53
            0
            • J JonB
              16 Aug 2020, 07:05

              @Natural_Bugger
              Did you try applying the principles shown in that last link to your Qt 5.9.9 situation?

              N Offline
              N Offline
              Natural_Bugger
              wrote on 16 Aug 2020, 07:19 last edited by
              #6

              @JonB

              add new kit?
              but how to point to "/usr/include/c++/9"?

              J N 2 Replies Last reply 16 Aug 2020, 07:23
              0
              • N Natural_Bugger
                16 Aug 2020, 07:19

                @JonB

                add new kit?
                but how to point to "/usr/include/c++/9"?

                J Offline
                J Offline
                JonB
                wrote on 16 Aug 2020, 07:23 last edited by
                #7

                @Natural_Bugger
                Sorry, I only know to follow the principle there, I can't tell you exactly what to do. For me I just accept it as-is initially under Ubuntu and it works fine, so someone else will have to help....

                N 1 Reply Last reply 16 Aug 2020, 08:24
                0
                • N Natural_Bugger
                  16 Aug 2020, 07:19

                  @JonB

                  add new kit?
                  but how to point to "/usr/include/c++/9"?

                  N Offline
                  N Offline
                  Natural_Bugger
                  wrote on 16 Aug 2020, 07:30 last edited by
                  #8

                  @Natural_Bugger

                  https://askubuntu.com/questions/859256/how-to-install-gcc-7-or-clang-4-0
                  sudo apt-get install gcc-8 g++-8

                  all fine and will install, but not to figure out where it is.

                  1 Reply Last reply
                  0
                  • J JonB
                    16 Aug 2020, 07:23

                    @Natural_Bugger
                    Sorry, I only know to follow the principle there, I can't tell you exactly what to do. For me I just accept it as-is initially under Ubuntu and it works fine, so someone else will have to help....

                    N Offline
                    N Offline
                    Natural_Bugger
                    wrote on 16 Aug 2020, 08:24 last edited by
                    #9

                    @JonB

                    thnx, very much sofar.

                    1 Reply Last reply
                    0
                    • N Natural_Bugger
                      16 Aug 2020, 07:12

                      @JonB

                      that's what I'm trying to figuring out.
                      that article applies to windows.

                      i'm not sure what to do now

                      J Offline
                      J Offline
                      J.Hilk
                      Moderators
                      wrote on 16 Aug 2020, 08:53 last edited by
                      #10

                      Hi @Natural_Bugger

                      You don't have to download a specific and new compiler, any you have installed should be c++14/17 capable.

                      You just have to tell it that you want to use a specific or the latest standard

                      hat's what I'm trying to figuring out.
                      that article applies to windows.

                      i'm not sure what to do now

                      doesn't matter if windows or not, the pricinple is the same.
                      To enable a specific c++ support you have to add to your pro file
                      CONFIG += C++17 for c++17 support, if you're using qt15 than c++latest is also an option

                      I'f you're using cmake as your build system, than this should set the compiler to c++17
                      set(CMAKE_CXX_STANDARD 17)


                      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                      Q: What's that?
                      A: It's blue light.
                      Q: What does it do?
                      A: It turns blue.

                      N 1 Reply Last reply 16 Aug 2020, 09:08
                      2
                      • J J.Hilk
                        16 Aug 2020, 08:53

                        Hi @Natural_Bugger

                        You don't have to download a specific and new compiler, any you have installed should be c++14/17 capable.

                        You just have to tell it that you want to use a specific or the latest standard

                        hat's what I'm trying to figuring out.
                        that article applies to windows.

                        i'm not sure what to do now

                        doesn't matter if windows or not, the pricinple is the same.
                        To enable a specific c++ support you have to add to your pro file
                        CONFIG += C++17 for c++17 support, if you're using qt15 than c++latest is also an option

                        I'f you're using cmake as your build system, than this should set the compiler to c++17
                        set(CMAKE_CXX_STANDARD 17)

                        N Offline
                        N Offline
                        Natural_Bugger
                        wrote on 16 Aug 2020, 09:08 last edited by Natural_Bugger
                        #11

                        @J-Hilk

                        hi and thnx,

                        i added " CONFIG += C++14 " to the project file.
                        C14 is enough to pass the test.
                        but i still get the same error.

                                int n = 9;
                                char grid[n][n];
                        
                                auto it=std::begin(grid);
                                cout<<"Hello"<<*(*it+1)<<endl;
                        

                        errors.

                        error: no matching function for call to 'begin'
                        error: no matching function for call to ‘begin(char [n][n])’
                           63 |         auto it=std::begin(grid);
                              |                                ^
                        

                        using lower case c, i have one less error.
                        " CONFIG += c++14 "

                        error: no matching function for call to ‘begin(char [n][n])’
                           63 |         auto it=std::begin(grid);
                              |     
                        ```                           ^
                        1 Reply Last reply
                        1
                        • J Offline
                          J Offline
                          JonB
                          wrote on 16 Aug 2020, 09:17 last edited by JonB
                          #12

                          I don't think you should be needing different compilers from what Ubuntu ships with.

                          I am not a C++ expert, but I'm not at all sure

                                  int n = 9;
                                  char grid[n][n];
                          
                                  auto it=std::begin(grid);
                          

                          is OK. For example, I think changing to constexpr int n = 9; will make it compile at the std::begin(). What evidence do you have that what you have written is supported? (Well that change makes it work with C++14, you may know more than I about which compiler version is wanted/required.)

                          N 1 Reply Last reply 16 Aug 2020, 09:25
                          3
                          • J JonB
                            16 Aug 2020, 09:17

                            I don't think you should be needing different compilers from what Ubuntu ships with.

                            I am not a C++ expert, but I'm not at all sure

                                    int n = 9;
                                    char grid[n][n];
                            
                                    auto it=std::begin(grid);
                            

                            is OK. For example, I think changing to constexpr int n = 9; will make it compile at the std::begin(). What evidence do you have that what you have written is supported? (Well that change makes it work with C++14, you may know more than I about which compiler version is wanted/required.)

                            N Offline
                            N Offline
                            Natural_Bugger
                            wrote on 16 Aug 2020, 09:25 last edited by
                            #13

                            @JonB

                            thank you very much and it did compile, even when return to c11.
                            : )

                            well, i want that piece of code to go over rows and columns in an elegant fashion, not using nested for loops.
                            i found that piece of code on stack exchange, than i found out it didn't compile on my system, but it did on online cpp compilers like: https://gcc.godbolt.org/ and you couldn't solve that ...

                            1 Reply Last reply
                            1

                            1/13

                            15 Aug 2020, 18:12

                            • Login

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