Qt 5.5 for Android "'to_string' was not declared in this scope"
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,
Hi and welcome to devnet,
The correct way to activate C++11 with Qt is to add
CONFIG += c++11to your .pro file.
Out of curiosity, since you are using Qt, why not use QString ?
@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?
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
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!