Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How do I compile my project using C++17?
Forum Updated to NodeBB v4.3 + New Features

How do I compile my project using C++17?

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 2 Posters 565 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.
  • L Offline
    L Offline
    lansing
    wrote on last edited by
    #1

    Hi I want to use some new features of C++17 for my project so I want to add it in the project file. But I don't know where to declare it.

    My project file starts something like this

    CONFIG += qt
    
    QT += widgets
    QT += network
    
    QT_VERSION_WARNING = "WARNING: Linking against Qt version lower than 5.6.1 is likely to cause CLI tools video encoding to crash due to I/O but in Qt."
    

    And then somewhere in the file it has another line mentioning about CONFIG += C++

    contains(QMAKE_COMPILER, gcc) {
    	QMAKE_CXXFLAGS += -std=c++11
    	QMAKE_CXXFLAGS += -Wall
    	QMAKE_CXXFLAGS += -Wextra
    	QMAKE_CXXFLAGS += -Wredundant-decls
    	QMAKE_CXXFLAGS += -Wshadow
    	#QMAKE_CXXFLAGS += -Weffc++
    	QMAKE_CXXFLAGS += -pedantic
    
    	LIBS += -L$$[QT_INSTALL_LIBS]
    } else {
            CONFIG += c++11
    }
    

    Where do I need to update it?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You should add CONFIG += c++17 to your .pro file for C++ 17. If you want the support for the latest standard supported by your compiler use "c++latest".

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      L 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        You should add CONFIG += c++17 to your .pro file for C++ 17. If you want the support for the latest standard supported by your compiler use "c++latest".

        L Offline
        L Offline
        lansing
        wrote on last edited by
        #3

        @SGaist

        Where do I add it? After the first line or change the one in that else statement?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          If you want to use it unconditionally, you should remove the mentions of C++11 completely and put the CONFiG line before the other changes.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          L 1 Reply Last reply
          0
          • SGaistS SGaist

            If you want to use it unconditionally, you should remove the mentions of C++11 completely and put the CONFiG line before the other changes.

            L Offline
            L Offline
            lansing
            wrote on last edited by
            #5

            @SGaist

            This line also? And change it to c++17?
            QMAKE_CXXFLAGS += -std=c++11

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              You should check why the gcc flags where modified that way and then see if the c++17 switch from CONFIG fills them in a compatible way. Otherwise, yes you have to replace it.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              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