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. make_unique<>() not found
Forum Update on Monday, May 27th 2025

make_unique<>() not found

Scheduled Pinned Locked Moved Solved General and Desktop
c++ makeunique
6 Posts 2 Posters 3.1k 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.
  • S Offline
    S Offline
    skylendar
    wrote on last edited by
    #1

    Hi there, I suppose this topic is not new, but in my case it is quit embarrassing.

    In a basic cpp test program compiled with gcc 7.3 x86_64 -std=gnu++17, I declare:

    auto p = make_unique<mytype>();
    cout << __cplusplus << endl;

    so far, so good. the prog compiles, runs and returns '201402' which is correct.
    However, when I try to compile a prog linked with Qt5.11 libraries, I got:

    error : use of undeclared identifier 'make_unique', and __cplusplus is set to '201103'.

    What's wrong ?

    aha_1980A 1 Reply Last reply
    0
    • S skylendar

      Hi there, I suppose this topic is not new, but in my case it is quit embarrassing.

      In a basic cpp test program compiled with gcc 7.3 x86_64 -std=gnu++17, I declare:

      auto p = make_unique<mytype>();
      cout << __cplusplus << endl;

      so far, so good. the prog compiles, runs and returns '201402' which is correct.
      However, when I try to compile a prog linked with Qt5.11 libraries, I got:

      error : use of undeclared identifier 'make_unique', and __cplusplus is set to '201103'.

      What's wrong ?

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by aha_1980
      #2

      hi @skylendar,

      I think you have to add CONFIG+=C++1z to your project .pro file.

      regards

      Edit: better look here: https://stackoverflow.com/questions/46610996/cant-use-c17-features-using-g-7-2-in-qtcreator

      Qt has to stay free or it will die.

      S 1 Reply Last reply
      2
      • aha_1980A aha_1980

        hi @skylendar,

        I think you have to add CONFIG+=C++1z to your project .pro file.

        regards

        Edit: better look here: https://stackoverflow.com/questions/46610996/cant-use-c17-features-using-g-7-2-in-qtcreator

        S Offline
        S Offline
        skylendar
        wrote on last edited by
        #3

        @aha_1980

        Thx for the answer, but I use CMake. So...

        aha_1980A S 2 Replies Last reply
        0
        • S skylendar

          @aha_1980

          Thx for the answer, but I use CMake. So...

          aha_1980A Offline
          aha_1980A Offline
          aha_1980
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @skylendar

          ... https://stackoverflow.com/questions/48501290/qtcreator-cmake-c17-features?r ?

          Qt has to stay free or it will die.

          1 Reply Last reply
          1
          • S skylendar

            @aha_1980

            Thx for the answer, but I use CMake. So...

            S Offline
            S Offline
            skylendar
            wrote on last edited by
            #5

            @skylendar

            Ah, I found finally:

            target_compile_features(myapp PUBLIC cxx_std_17)

            aha_1980A 1 Reply Last reply
            1
            • S skylendar

              @skylendar

              Ah, I found finally:

              target_compile_features(myapp PUBLIC cxx_std_17)

              aha_1980A Offline
              aha_1980A Offline
              aha_1980
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @skylendar

              then please mark this topic as SOLVED. thanks

              Qt has to stay free or it will die.

              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