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?
QtWS25 Last Chance

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.0k Views
  • 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 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.HilkJ 1 Reply Last reply
    0
    • N Natural_Bugger

      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.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on 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
      2
      • J.HilkJ J.Hilk

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

        JonBJ 1 Reply Last reply
        0
        • N Natural_Bugger

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

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on 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
          0
          • JonBJ JonB

            @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 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.HilkJ 1 Reply Last reply
            0
            • JonBJ JonB

              @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 last edited by
              #6

              @JonB

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

              JonBJ N 2 Replies Last reply
              0
              • N Natural_Bugger

                @JonB

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

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on 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
                0
                • N Natural_Bugger

                  @JonB

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

                  N Offline
                  N Offline
                  Natural_Bugger
                  wrote on 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
                  • JonBJ JonB

                    @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 last edited by
                    #9

                    @JonB

                    thnx, very much sofar.

                    1 Reply Last reply
                    0
                    • N Natural_Bugger

                      @JonB

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

                      i'm not sure what to do now

                      J.HilkJ Offline
                      J.HilkJ Offline
                      J.Hilk
                      Moderators
                      wrote on 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
                      2
                      • J.HilkJ J.Hilk

                        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 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
                        • JonBJ Offline
                          JonBJ Offline
                          JonB
                          wrote on 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
                          3
                          • JonBJ JonB

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

                            • Login

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