Qt Forum

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

    [SOLVED][Linux] make_unique and GCC compiler

    General and Desktop
    2
    5
    11211
    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.
    • H
      helthans last edited by

      Hi,

      I am porting code from Visual Studio 2013. One of the functions use make_unique
      @myVar = make_unique<T>(...)@

      I get the following error:
      @'make_unique' was not declared in this scope@

      I googled a bit and have found that 'make_unique' should be part of gcc4.9. Hence, I installed gcc4.9 on my system and compiled Qt5.3.2 and QtCreator using gcc4.9.

      The problem is that I still get the same error. Can anyone tell me how to proceed?

      1 Reply Last reply Reply Quote 0
      • S
        sandy.martel last edited by

        std:: make_unique is part of C++14. You need to compile with this option:
        -std=gnu++14

        1 Reply Last reply Reply Quote 0
        • H
          helthans last edited by

          Thanks a lot for the reply.
          Not sure if I did it correct. I added
          @QMAKE_CXXFLAGS += -std=gnu++14@

          to my .pro file

          It still fails and I see the following compile output
          @g++ -c -std=gnu++14 -g -std=c++0x -Wall -W -D_REENTRANT -fPIC -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_CORE_LIB -I../../../../dev/qt5/qtbase/mkspecs/linux-g++ -I../../../BeatQtPlayer/src/MediaButlerMixSchedule -I../../../BeatQtPlayer/src -I../../../../dev/qt5/qtbase/include -I../../../../dev/qt5/qtbase/include/QtCore -I. -I. -o ScheduleCtrlV2.o ../../../BeatQtPlayer/src/MediaButlerMixSchedule/ScheduleCtrlV2.cpp@

          I'd assume that the issue is '-std=c++0x' (?!) If that's the case, how do I get rid of this option?

          1 Reply Last reply Reply Quote 0
          • S
            sandy.martel last edited by

            I can't see the error in your output, but I would think you are right. You can try
            QMAKE_CXXFLAGS -= -std=C++0x

            But I have no idea to tell you the thruth. I just know you need
            c++14 for that make_unique.

            1 Reply Last reply Reply Quote 0
            • H
              helthans last edited by

              Adding
              @CONFIG += c++14@
              to my .pro file fixed the problem

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