本文介绍了错误:名称空间'std'中没有名为'to_string'的成员;你的意思是'toString'?摇篮+ cmake的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
包含 < string>
。 std :: to_sting(intVar)
中有什么错误?
帮助,但答案不是很好(对我来说),因为:
- 写入自己的std :: to_string()是个坏主意。标准是标准的。如果我写自己的实现。我需要用定义来包装它,以防止来自其他编译器/工具链的不会泄漏std特性的错误。而这个impl仍然会泄露功能全面的STD。
-
Application.mk
- 由于最新的Studio提供了Gradle + CMake, Makefile太难以用于手动使用。 - 我的更好。
- write own std::to_string() is bad idea. Standard is standard. If i write own implementation. I need to wrap it with defines to prevent errors from another compilers/toolchains which does not leak std features. And this impl still leaks full-featured STD.
Application.mk
- is bad idea too since lastest studio offers Gradle+CMake. Makefile is too ugly and hard for manual using.- My solution is better.
ol>
解决方案
不,这是因为默认情况下,在Android NDK中设置的最小std库。
我使用gradle构建系统:
android {
...
defaultConfig {
...
//此块与您用来将Gradle
//链接到您的CMake构建脚本的块不同。
externalNativeBuild {
cmake {
...
//将参数传递给变量时使用以下语法:
//参数-DVAR_NAME = VALUE
// ------------------- ANSWER -------------------
arguments - DANDROID_STL = c ++ _ shared
}
}
buildTypes {...}
//使用此块将Gradle链接到您的CMake构建脚本。
externalNativeBuild {
cmake {...}
}
}
阅读以下内容:
<string>
is included. What is wrong in std::to_sting(intVar)
?
cppreference. Does it mean CLang does not meet STandarD?
Another question helped, but the answers are not good (for me) because:
解决方案
No, it is because minimal std library set in Android NDK by default.
I use gradle build system:
android {
...
defaultConfig {
...
// This block is different from the one you use to link Gradle
// to your CMake build script.
externalNativeBuild {
cmake {
...
// Use the following syntax when passing arguments to variables:
// arguments "-DVAR_NAME=VALUE"
// ------------------- ANSWER -------------------
arguments "-DANDROID_STL=c++_shared"
}
}
}
buildTypes {...}
// Use this block to link Gradle to your CMake build script.
externalNativeBuild {
cmake {...}
}
}
Read these:
https://developer.android.com/ndk/guides/cmake.html#variables
https://developer.android.com/ndk/guides/cpp-support.htm
这篇关于错误:名称空间'std'中没有名为'to_string'的成员;你的意思是'toString'?摇篮+ cmake的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!