{"id":990,"date":"2023-03-12T07:48:37","date_gmt":"2023-03-11T23:48:37","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=990"},"modified":"2023-04-29T13:22:17","modified_gmt":"2023-04-29T05:22:17","slug":"android-ndk-calling-cpp-standard-library-issue","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/12\/android-ndk-calling-cpp-standard-library-issue\/","title":{"rendered":"Android NDK\u8c03\u7528C++\u6807\u51c6\u5e93\u95ee\u9898"},"content":{"rendered":"<p>\u5728Android NDK\u9879\u76ee\u6dfb\u52a0cpp\u6587\u4ef6\uff0c\u5e76\u5f15\u7528C++\u6807\u51c6\u5e93\u5934\u6587\u4ef6\uff1a<\/p>\n<pre><code class=\"language-cpp\">#include &lt;string&gt;\n#include &lt;iostream&gt;<\/code><\/pre>\n<p><!-- more --><\/p>\n<p>\u4f7f\u7528<code>ndk-build<\/code>\u7f16\u8bd1\u62a5\u5982\u4e0b\u9519\u8bef\uff1a<\/p>\n<pre><code>fatal error: &#039;string&#039; file not found\nfatal error: &#039;iostream&#039; file not found<\/code><\/pre>\n<blockquote>\n<p>\u539f\u56e0\uff1a\u5728\u4f7f\u7528C++\u7684\u6807\u51c6\u5e93\u8fdb\u884cNDK\u5f00\u53d1\u65f6\uff0c\u5fc5\u987b\u8bbe\u7f6eAPP_STL<\/p>\n<\/blockquote>\n<h3>Application.mk\u89e3\u51b3\u65b9\u6848<\/h3>\n<p>\u5728jni\u6587\u4ef6\u5939\u4e0b\u65b0\u5efaApplication.mk\u6587\u4ef6\uff0c\u5e76\u52a0\u5165\uff1a<\/p>\n<pre><code>#\u4ee5\u4e0b\u4e24\u884c\u4e8c\u9009\u4e00\nAPP_STL  := stlport_static\n#APP_STL := gnustl_static<\/code><\/pre>\n<h3>Gradle\u89e3\u51b3\u65b9\u6848<\/h3>\n<pre><code>android.defaultConfig.ndk {\n    moduleName = &quot;hello-jni&quot;\n    stl \u00a0 \u00a0 \u00a0 \u00a0= &quot;stlport_static&quot;\n}<\/code><\/pre>\n<h3>APP_STL<\/h3>\n<p>APP_STL\u53ef\u53d6\u8303\u56f4\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/developer.android.com\/ndk\/guides\/cpp-support#c_runtime_libraries\">https:\/\/developer.android.com\/ndk\/guides\/cpp-support#c_runtime_libraries<\/a><\/p>\n<p>\u4e0d\u540c\u7684\u6807\u51c6\u5e93\u80fd\u529b\u4e5f\u5404\u6709\u5dee\u5f02\uff0c\u89c1\u4e0b\u8868<\/p>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: center;\">APP_STL<\/th>\n<th style=\"text-align: center;\">C++ Exceptions<\/th>\n<th style=\"text-align: center;\">C++ RTTI<\/th>\n<th style=\"text-align: center;\">Standard Library<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: center;\">system<\/td>\n<td style=\"text-align: center;\">no<\/td>\n<td style=\"text-align: center;\">no<\/td>\n<td style=\"text-align: center;\">no<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">gabi++<\/td>\n<td style=\"text-align: center;\">no<\/td>\n<td style=\"text-align: center;\">yes<\/td>\n<td style=\"text-align: center;\">no<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">stlport<\/td>\n<td style=\"text-align: center;\">no<\/td>\n<td style=\"text-align: center;\">yes<\/td>\n<td style=\"text-align: center;\">yes<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">gnustl<\/td>\n<td style=\"text-align: center;\">yes<\/td>\n<td style=\"text-align: center;\">yes<\/td>\n<td style=\"text-align: center;\">yes<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u7279\u522b\u6ce8\u610f\u7684\u662f\uff0c\u5f15\u7528\u7684\u7c7b\u5e93\u8d8a\u5168\u9762\uff0c\u6700\u540e\u751f\u6210\u7684\u5e93\u6587\u4ef6\u4f53\u79ef\u4e5f\u8d8a\u5927\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728Android NDK\u9879\u76ee\u6dfb\u52a0cpp\u6587\u4ef6\uff0c\u5e76\u5f15\u7528C++\u6807\u51c6\u5e93\u5934\u6587\u4ef6\uff1a #include &lt;string [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-990","post","type-post","status-publish","format-standard","hentry","category-android-ndk"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/990","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=990"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/990\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=990"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=990"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=990"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}