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. [SOLVED][Linux] make_unique and GCC compiler
QtWS25 Last Chance

[SOLVED][Linux] make_unique and GCC compiler

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 11.9k 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.
  • H Offline
    H Offline
    helthans
    wrote on last edited by
    #1

    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
    0
    • S Offline
      S Offline
      sandy.martel
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      • H Offline
        H Offline
        helthans
        wrote on last edited by
        #3

        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
        0
        • S Offline
          S Offline
          sandy.martel
          wrote on last edited by
          #4

          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
          0
          • H Offline
            H Offline
            helthans
            wrote on last edited by
            #5

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

            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