Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Qt 5.5 for Android "'to_string' was not declared in this scope"
Forum Updated to NodeBB v4.3 + New Features

Qt 5.5 for Android "'to_string' was not declared in this scope"

Scheduled Pinned Locked Moved Solved Mobile and Embedded
5 Posts 2 Posters 2.8k Views 1 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.
  • M Offline
    M Offline
    mkeezy
    wrote on last edited by mkeezy
    #1

    Hello!

    I'm having some problems porting my Qt application to android. The one thing I can't get my head around is the ARM 7 compiler not resolving 'to_string' and claiming it's not declared in the scope.

    This is the line that breaks my code:

    frontend.setCountdownText(timer1, "Long text, long text, long long text... Disabling first effects in " + to_string(frontend.getTimerValue(timer1)) + " ms...");
    

    It worked perfectly when building with GCC 64 bit. I made sure to add "CONFIG += c++11" to the .pro file and also tried "QMAKE_CXXFLAGS += -std=c++11". None of that made it work. Replacing "c++11" with "c++0x" didn't help either.

    I browsed this error for quite a while before making this post. Most suggestions revolve around explicitly using C++ 2011, but as mentioned above I'm already doing that.

    Any help or hint would be greatly appreciated.

    Thanks in advance,

    Max

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

      Hi and welcome to devnet,

      The correct way to activate C++11 with Qt is to add CONFIG += c++11 to your .pro file.

      Out of curiosity, since you are using Qt, why not use QString ?

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

      M 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi and welcome to devnet,

        The correct way to activate C++11 with Qt is to add CONFIG += c++11 to your .pro file.

        Out of curiosity, since you are using Qt, why not use QString ?

        M Offline
        M Offline
        mkeezy
        wrote on last edited by
        #3

        @SGaist Thanks a lot for the quick reply! As I said, I already included "CONFIG += c++11" in my .pro file.

        Up until this point the code was developed by someone else, so I actually don't know why they used string instead of QString. I'm gonna try to refactor the code in order to use QString, maybe that will help.
        But still, it should be possible to make it work with std::string, right?

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

          Sorry, I misread the .pro file part of your post.

          It should but it also seems that the Android NDK doesn't provide all the std::string functions so depending on your NDK version you might not have it.

          You can see here an implementation example that you could use

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

            Seems like my NDK version is among those who don't support to_string. I implemented it manually and now it works. Thanks again for your help, much appreciated!

            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