{"id":23,"date":"2023-03-29T20:22:01","date_gmt":"2023-03-29T12:22:01","guid":{"rendered":"https:\/\/code.lingapi.top\/?p=23"},"modified":"2023-04-01T13:24:57","modified_gmt":"2023-04-01T05:24:57","slug":"%e8%ae%b0%e5%bd%95%e4%b8%80%e6%ac%a1%e8%89%b0%e9%9a%be%e7%9a%84c%e4%be%9d%e8%b5%96%e9%a1%b9%e9%85%8d%e7%bd%ae%e8%bf%87%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/code.lingapi.top\/?p=23","title":{"rendered":"\u8bb0\u5f55\u4e00\u6b21\u8270\u96be\u7684C++\u4f9d\u8d56\u9879\u914d\u7f6e\u8fc7\u7a0b"},"content":{"rendered":"\n<p>\u51e0\u5929\u524d\uff0c\u6211\u60f3\u8981\u5236\u4f5c\u4e00\u6b3eC++\u5b9e\u73b0\u7684\u540e\u7aef\u4e91\u5bf9\u63a5\u5e93\uff0c\u9884\u8ba1\u5c06\u8981\u5b9e\u73b0Java\u7248\u7c7b\u5e93\u7684\u5b8c\u6574\u529f\u80fd\u3002\u6211\u51c6\u5907\u4f7f\u7528libcurl\u6765\u5b8c\u6210https\u8bf7\u6c42\u548c\u8bc1\u4e66\u56fa\u5b9a\u7684\u4efb\u52a1\u3002<\/p>\n\n\n\n<p>\u5728\u9879\u76ee\u914d\u7f6e\u8fc7\u7a0b\u4e2d\uff0c\u6211\u5e0c\u671b\u9879\u76ee\u80fd\u5728Linux\u4e0b\u76f4\u63a5\u8fd0\u884c\uff0c\u4ee5\u65b9\u4fbf\u5f00\u53d1\u8fc7\u7a0b\u4e2d\u7684\u8c03\u8bd5\u5de5\u4f5c\u3002\u53c8\u5e0c\u671b\u6b63\u5f0f\u6253\u5305\u65f6\uff0c\u80fd\u4e00\u6b21\u6027\u5c06Android\u7684\u56db\u4e2aABI\u90fd\u6784\u5efa\u51fa\u6765\uff0c\u5e76\u4e14\u5305\u542bAndroid\u5e73\u53f0\u7684\u53ef\u6267\u884c\u6587\u4ef6\u3002\u4e8e\u662f\uff0c\u6211\u4f7f\u7528\u4e86sh\u6784\u5efa\u811a\u672c\u3002<\/p>\n\n\n\n<p>\u5728\u8be5\u811a\u672c\u4e2d\uff0c\u624b\u52a8\u6307\u5b9aAndroid NDK\u7684\u4f4d\u7f6e\u548c\u4f7f\u7528\u7684\u4ea4\u53c9\u7f16\u8bd1\u5de5\u5177\u94fe\uff0c\u4ee5\u53ca\u7f16\u8bd1\u7684\u76ee\u6807SDK\u7248\u672c\u53f7\u3002\u5728cmake\u4e2d\u5224\u65adsh\u4f20\u5165\u7684\u73af\u5883\u53d8\u91cf\u6765\u4e3a\u7279\u5b9a\u7684\u5e73\u53f0\u4f7f\u7528\u7279\u5b9a\u7684\u5de5\u5177\u94fe\uff0c\u81f3\u6b64\u4e3a\u6b62\u4e00\u5207\u6b63\u5e38\u3002<\/p>\n\n\n\n<p>\u4f7f\u7528libcurl\u9700\u8981\u624b\u52a8\u7f16\u8bd1libcurl\u7684\u4f9d\u8d56\u9879\uff0c\u6211\u5148\u662f\u4ece\u7f51\u7edc\u4e0a\u4e0b\u8f7d\u4e86\u4e3aAndroid\u9884\u7f16\u8bd1\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\uff0c\u53ef\u662f\u5728cmake\u4e2d\u4f7f\u7528\u65f6\u7f16\u8bd1\u5668\u94fe\u63a5\u603b\u51fa\u9519\uff0c\u6211\u4ee5\u4e3a\u662f\u6211\u7684cmake\u67e5\u627e\u8def\u5f84\u914d\u7f6e\u9519\u4e86\uff0c\u53ef\u662fAI\u53cd\u590d\u68c0\u67e5\u6211\u7684cmake\uff0c\u7ed9\u51fa\u7684\u5efa\u8bae\u90fd\u662f\u68c0\u67e5\u67e5\u627e\u8def\u5f84\u3002\u540e\u7ec8\u4e8e\u53d1\u73b0\u662f\u7f51\u7edc\u4e0a\u4e0b\u8f7d\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\u683c\u5f0f\u4e0d\u5bf9\u3002\u4f7f\u7528readelf\u5de5\u5177\u68c0\u67e5\u540e\uff0c\u53d1\u73b0\u5728arm\u548carm64\u6587\u4ef6\u5939\u4e0b\u7684\u9759\u6001\u5e93\u90fd\u662fx86\u683c\u5f0f\u7684\u3002\u6545\u5f00\u59cb\u624b\u52a8\u7f16\u8bd1\u4f9d\u8d56\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u7f16\u8bd1\u8fc7\u7a0b<\/h2>\n\n\n\n<p>\u8981\u4f7f\u7f16\u8bd1\u5f97\u5230\u7684libcurl\u652f\u6301https\uff0c\u90a3\u4e48\u7f16\u8bd1\u8fc7\u7a0b\u4e2d\u5fc5\u987b\u5f15\u5165openssl\u4f9d\u8d56\uff0c\u800c\u4e14libcurl\u8fd8\u4f9d\u8d56libz\u3002libz\u7f16\u8bd1\u76f8\u5bf9\u7b80\u5355\uff0c\u9996\u5148\u7f16\u8bd1libz\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u73af\u5883\u53d8\u91cf<\/h2>\n\n\n\n<p>\u5728\u7f16\u8bd1\u8fc7\u7a0b\u4e2d\uff0c\u9700\u8981\u5b9a\u4e49\u4ee5\u4e0b\u73af\u5883\u53d8\u91cf\uff0c\u4ee5\u4fbf\u6784\u5efa\u5de5\u5177\u80fd\u627e\u5230\u9700\u8981\u7684\u7f16\u8bd1\u5668\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash\n<em>#NDK\u8def\u5f84\uff0copenssl\u9700\u8981ANDROID_NDK_ROOT\u53d8\u91cf\uff0c\u6240\u4ee5\u628a\u5b83export\u4e00\u4e0b<\/em>\nexport ANDROID_NDK_ROOT=$HOME\/Library\/Android\/sdk\/ndk\/23.1.7779620\n\n<em>#\u7f16\u8bd1\u5e73\u53f0\uff0c\u6211\u8fd9\u91cc\u662flinux\uff0c\u6240\u4ee5\u662flinux-x86_64<\/em>\nHOST_TAG=linux-x86_64\n\n<em>#Android api\u7248\u672c<\/em>\nMIN_SDK_VERSION=23\n\n<em>#\u5de5\u5177\u94fe\u8def\u5f84<\/em>\nTOOLCHAIN=$ANDROID_NDK_ROOT\/toolchains\/llvm\/prebuilt\/$HOST_TAG\n\n<em>#\u628a\u5de5\u5177\u94fe\u52a0\u5230PATH\u73af\u5883\u53d8\u91cf<\/em>\nPATH=$TOOLCHAIN\/bin:$PATH\n\n<em>#\u8f93\u51fa\u76ee\u5f55\uff0c\u5728build\u76ee\u5f55\u4e0b<\/em>\nBUILD_DIR=$PWD\/build<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u7f16\u8bd1libz<\/h2>\n\n\n\n<p>\u89e3\u538bzlib\uff0c\u5e76cd\u5230zlib\u76ee\u5f55\u4e0b<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>tar xvf zlib-1.2.13.tar.gz\ncd zlib-1.2.13<\/code><\/pre>\n\n\n\n<p>\u914d\u7f6e\u7f16\u8bd1\u5de5\u5177\u94fe\uff0c\u5c31\u662f\u914d\u7f6eC\/C++\u7f16\u8bd1\u5668\u3001\u6c47\u7f16\u5668\u3001\u94fe\u63a5\u5668\u7684\u8def\u5f84\uff0c\u7531\u4e8eAndroid\u5df2\u7ecf\u653e\u5f03\u4e86gcc\uff0c\u73b0\u5728\u7684\u7f16\u8bd1\u5668\u662fclang\u548cclang++\u3002<\/p>\n\n\n\n<p>\u8981\u9002\u7528\u4e8e\u6240\u6709CPU\u67b6\u6784\uff0c\u6211\u4eec\u8981\u7f16\u8bd1armv8\u3001armv7\u3001x86\u3001x86_64\u56db\u4e2a\u5e73\u53f0\u3002\u4ed6\u4eec\u4f1a\u4f7f\u7528\u4e0d\u540c\u7684clang\u6765\u7f16\u8bd1\u3002\u6211\u4eec\u7528TARGET_HOST\u6765\u533a\u5206\u3002 aarch64-linux-android\u8868\u793a\u8981\u7f16\u8bd1armv8 armv7a-linux-androideabi\u8868\u793a\u8981\u7f16\u8bd1armv7a i686-linux-android\u8868\u793a\u8981\u7f16\u8bd1x86 x86_64-linux-android\u8868\u793a\u8981\u7f16\u8bd1x86_64<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>TARGET_HOST=aarch64-linux-android\nANDROID_ARCH=arm64-v8a\nAR=$TOOLCHAIN\/bin\/llvm-ar\nCC=$TOOLCHAIN\/bin\/$TARGET_HOST$MIN_SDK_VERSION-clang\nAS=$CC\nCXX=$TOOLCHAIN\/bin\/$TARGET_HOST$MIN_SDK_VERSION-clang++\nLD=$TOOLCHAIN\/bin\/ld\nRANLIB=$TOOLCHAIN\/bin\/llvm-ranlib\nSTRIP=$TOOLCHAIN\/bin\/llvm-strip<\/code><\/pre>\n\n\n\n<p>\u914d\u7f6e\u597d\u5de5\u5177\u94fe\u540e\u6267\u884cconfigure\u3002&#8211;prefix\u6307\u5b9a\u7f16\u8bd1\u5b8c\u6210\u540e\u8f6f\u4ef6\u7684\u5b89\u88c5\u76ee\u5f55\u3002&#8211;static\u53ea\u7f16\u8bd1\u9759\u6001\u5e93\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>INSTALL_DIR=$BUILD_DIR\/zlib\n.\/configure --prefix=$INSTALL_DIR\/$ANDROID_ARCH --static\n<em>#\u4e0a\u9762\u8bbe\u7f6e\u4e86BUILD_DIR\u4e3a\u6839\u76ee\u5f55build\u6587\u4ef6\u5939\uff0c\u6240\u4ee5$INSTALL_DIR\/$ANDROID_ARCH\u7684\u503c\u4e3a build\/zlib\/arm64-v8a<\/em><\/code><\/pre>\n\n\n\n<p>\u518d\u6267\u884cmake\u3001make install\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>make\n\nmake install<\/code><\/pre>\n\n\n\n<p>install\u540e\uff0c\u5728\u6839\u76ee\u5f55build\/curl\u4e0b\uff0c\u51fa\u73b0\u4e86arm64-v8a\u3002\u91cc\u9762\u5c31\u662farm64-v8a\u7248\u672c\u7684zlib\u5e93\u3002<\/p>\n\n\n\n<p>\u6211\u628a\u56db\u4e2a\u67b6\u6784\u7684\u7f16\u8bd1\u5199\u6210shell\u6587\u4ef6\u3002<\/p>\n\n\n\n<p>build-zlib.sh<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash\n\ntar xzf zlib-1.2.13.tar.gz\n\nsource .\/build-env.sh\n\nINSTALL_DIR=$BUILD_DIR\/zlib\n\nif &#91; ! -d $INSTALL_DIR ]; then\n    mkdir -p $INSTALL_DIR\nfi\n\ncd zlib-1.2.13\n\n\nfunction build() {\n    make distclean\n    TARGET_HOST=$1\n    ANDROID_ARCH=$2\n    AR=$TOOLCHAIN\/bin\/llvm-ar\n    CC=$TOOLCHAIN\/bin\/$TARGET_HOST$MIN_SDK_VERSION-clang\n    AS=$CC\n    CXX=$TOOLCHAIN\/bin\/$TARGET_HOST$MIN_SDK_VERSION-clang++\n    LD=$TOOLCHAIN\/bin\/ld\n    RANLIB=$TOOLCHAIN\/bin\/llvm-ranlib\n    STRIP=$TOOLCHAIN\/bin\/llvm-strip\n\n    .\/configure --prefix=$INSTALL_DIR\/$ANDROID_ARCH --static\n\n    make -j8\n    make install\n    make distclean\n}\n\nbuild aarch64-linux-android arm64-v8a\nbuild armv7a-linux-androideabi armeabi-v7a\nbuild i686-linux-android x86\nbuild x86_64-linux-android x86_64\n\ncd ..\n\nrm -rf cd zlib-1.2.13<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u7f16\u8bd1openssl<\/h2>\n\n\n\n<p>\u901a\u8fc7\u4e0a\u9762\u7684zlib\u7f16\u8bd1\uff0copenssl\u7684\u7f16\u8bd1\u6d41\u7a0b\u5927\u81f4\u662f\u4e00\u6837\u7684\uff0c\u89e3\u538b\u4ee3\u7801\u4ec0\u4e48\u7684\u5c31\u6ca1\u5fc5\u8981\u8bb0\u5f55\u4e86\u3002<\/p>\n\n\n\n<p>\u6709\u70b9\u4e0d\u4e00\u6837\u7684\u662fopenssl\u7684Configure\u662f\u5927\u5199\u7684\u3002\u5e76\u4e14\u5b83\u81ea\u5df1\u652f\u6301\u4e86Android\uff0c\u9700\u8981\u901a\u8fc7\u53c2\u6570\u4f20\u9012\u7ed9\u5b83\u3002<\/p>\n\n\n\n<p>\u7136\u540e\u5c31\u662f\u6211\u4f7f\u7528r21\u7684NDK\u7f16\u8bd1\u65f6\u4f1a\u627e\u4e0d\u5230\u4e00\u4e9b\u5934\u6587\u4ef6\uff0c\u53ef\u80fd\u662f\u7531\u4e8e\u6211\u5b89\u88c5llvm\u7684\u65f6\u5019\u635f\u574f\u4e86NDK\uff0c\u6362\u4e86\u4e00\u4e2a\u4e4b\u540e\u5c31\u597d\u4e86\u3002<\/p>\n\n\n\n<p>android-arm64\u8868\u793a\u7f16\u8bd164\u4f4d\u7684arm\u7248\u672c\u3002<\/p>\n\n\n\n<p>no-unit-test\u8868\u793a\u4e0d\u9700\u8981\u5355\u5143\u6d4b\u8bd5\u3002<\/p>\n\n\n\n<p>no-shared\u8868\u793a\u4e0d\u9700\u8981\u52a8\u6001\u5e93\u3002<\/p>\n\n\n\n<p>-D<strong>ANDROID_API<\/strong>=$MIN_SDK_VERSION\u4f20\u9012Android api\u7248\u672c\u3002<\/p>\n\n\n\n<p>&#8211;prefix\u6307\u5b9aAndroid\u76ee\u5f55<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.\/Configure android-arm64 no-unit-test no-shared -D__ANDROID_API__=$MIN_SDK_VERSION --prefix=$INSTALL_DIR\/$ANDROID_ARCH<\/code><\/pre>\n\n\n\n<p>\u540c\u6837\u5199\u6210shell\u6587\u4ef6<\/p>\n\n\n\n<p>build-openssl.sh<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash\n\ntar xzf openssl-3.0.7.tar.gz\n\nsource .\/build-env.sh\n\nINSTALL_DIR=$BUILD_DIR\/openssl\n\nif &#91; ! -d $INSTALL_DIR ]; then\n    mkdir -p $INSTALL_DIR\nfi\n\ncd openssl-3.0.7\n\nfunction build() {\n    TARGET_HOST=$1\n    ANDROID_ARCH=$2\n    OPENSSL_ARCH=$3\n    AR=$TOOLCHAIN\/bin\/llvm-ar\n    CC=$TOOLCHAIN\/bin\/$TARGET_HOST$MIN_SDK_VERSION-clang\n    AS=$CC\n    CXX=$TOOLCHAIN\/bin\/$TARGET_HOST$MIN_SDK_VERSION-clang++\n    LD=$TOOLCHAIN\/bin\/ld\n    RANLIB=$TOOLCHAIN\/bin\/llvm-ranlib\n    STRIP=$TOOLCHAIN\/bin\/llvm-strip\n\n    .\/Configure $OPENSSL_ARCH no-unit-test no-shared -D__ANDROID_API__=$MIN_SDK_VERSION --prefix=$INSTALL_DIR\/$ANDROID_ARCH\n\n    make -j8\n    make install_sw\n    make distclean\n}\n\nbuild aarch64-linux-android arm64-v8a android-arm64\nbuild armv7a-linux-androideabi armeabi-v7a android-arm\nbuild i686-linux-android x86 android-x86\nbuild x86_64-linux-android x86_64 android-x86_64\n\n\ncd ..\n\nrm -rf openssl-3.0.7<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u7f16\u8bd1curl<\/h2>\n\n\n\n<p>\u51c6\u5907\u5b8czlib\u548copenssl\u4e4b\u540e\uff0c\u5c31\u53ef\u4ee5\u7f16\u8bd1curl\u4e86\u3002\u540c\u6837\u662f\u8001\u5957\u8def\uff0cconfigure\uff0cmake\uff0cmake install\u3002<\/p>\n\n\n\n<p>&#8211;host\u548c&#8211;target\u628a\u7f16\u8bd1\u5668\u5e73\u53f0\u4f20\u7ed9\u5b83\u3002<\/p>\n\n\n\n<p>&#8211;prefix\u4f9d\u65e7\u8fd8\u662f\u5b89\u88c5\u76ee\u5f55\u3002<\/p>\n\n\n\n<p>&#8211;with-zlib\u548c&#8211;with-openssl\u5c31\u7528\u5230\u4e86\u6211\u4eec\u4e0a\u9762\u7f16\u8bd1\u51fa\u6765\u7684zlib\u548copenssl\u3002\u6211\u4eec\u628a\u76ee\u5f55\u4f20\u7ed9\u5b83\u3002<\/p>\n\n\n\n<p>&#8211;disable-shared\u8868\u793a\u4e0d\u7f16\u8bd1\u52a8\u6001\u5e93\uff0c\u6211\u53ea\u9700\u8981\u9759\u6001\u5e93\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.\/configure --host=$TARGET_HOST \\\n            --target=$TARGET_HOST \\\n            --prefix=$INSTALL_DIR\/$ANDROID_ARCH \\\n            --with-zlib=$BUILD_DIR\/zlib\/$ANDROID_ARCH \\\n            --with-openssl=$BUILD_DIR\/openssl\/$ANDROID_ARCH \\\n            --disable-shared<\/code><\/pre>\n\n\n\n<p>curl\u7684\u5b8c\u6574\u7f16\u8bd1\u6587\u4ef6\u5982\u4e0b<\/p>\n\n\n\n<p>build-curl.sh<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash\n\ntar xzf curl-7.88.0.tar.xz\n\nsource .\/build-env.sh\n\nINSTALL_DIR=$BUILD_DIR\/curl\n\nif &#91; ! -d $INSTALL_DIR ]; then\n    mkdir -p $INSTALL_DIR\nfi\n\ncd curl-7.88.0\n\n\nfunction build() {\n    export TARGET_HOST=$1\n    export ANDROID_ARCH=$2\n    export AR=$TOOLCHAIN\/bin\/llvm-ar\n    export CC=$TOOLCHAIN\/bin\/$TARGET_HOST$MIN_SDK_VERSION-clang\n    export AS=$CC\n    export CXX=$TOOLCHAIN\/bin\/$TARGET_HOST$MIN_SDK_VERSION-clang++\n    export LD=$TOOLCHAIN\/bin\/ld\n    export RANLIB=$TOOLCHAIN\/bin\/llvm-ranlib\n    export STRIP=$TOOLCHAIN\/bin\/llvm-strip\n\n    .\/configure --host=$TARGET_HOST \\\n                --target=$TARGET_HOST \\\n                --prefix=$INSTALL_DIR\/$ANDROID_ARCH \\\n                --with-zlib=$BUILD_DIR\/zlib\/$ANDROID_ARCH \\\n                --with-openssl=$BUILD_DIR\/openssl\/$ANDROID_ARCH \\\n                --with-pic --disable-shared\n\n    make -j8\n    make install\n    make clean\n}\n\n\nbuild aarch64-linux-android arm64-v8a\nbuild armv7a-linux-androideabi armeabi-v7a\nbuild i686-linux-android x86\nbuild x86_64-linux-android x86_64\n\ncd ..\n\nrm -rf cd curl-7.88.0<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u94fe\u63a5\u95ee\u9898<\/h2>\n\n\n\n<p>\u5728\u4f7f\u7528\u4e0a\u9762\u7f16\u8bd1\u5f97\u5230\u7684\u5e93\u6587\u4ef6\u7684\u65f6\u5019\uff0c\u51fa\u73b0\u4e86\u5f88\u591a\u95ee\u9898\u3002<\/p>\n\n\n\n<p>\u9996\u5148\uff0c\u662fstderr\uff0cstdout\u548cstdin\u8fd9\u4e09\u4e2aC\u8bed\u8a00\u7684\u6807\u51c6\u8f93\u5165\u8f93\u51fa\u94fe\u63a5\u51fa\u9519\u3002\u94fe\u63a5\u5668\u8868\u793a\u627e\u4e0d\u5230\u8fd9\u4e9b\u7b26\u53f7\uff0c\u4f46\u662f\u5b83\u4eec\u90fd\u662fC\u6807\u51c6\u5e93\u7684\u4e00\u90e8\u5206\uff0c\u5e94\u8be5\u662f\u9ed8\u8ba4\u5305\u542b\u7684\u3002\u7f51\u7edc\u4e0a\u7ed9\u51fa\u4e86\u4e00\u5219\u6d88\u606f\u8bef\u5bfc\u4e86\u6211\uff0c\u6211\u627e\u5230\u4e00\u5219\u6d88\u606f\u6307\u51faGoogle\u5728NDK r21\u5f00\u59cb\u5220\u9664\u4e86C\u7684\u6807\u51c6\u8f93\u5165\u8f93\u51fa\uff0c\u7406\u7531\u662f\u5728Android\u4e0a\u6709\u7279\u6b8a\u7684\u8f93\u5165\u8f93\u51fa\u8bbe\u5907\u3002\u4f46\u662f\u8fd9\u4e9b\u5185\u5bb9\u90fd\u662f\u5728\u6211\u4f7f\u7528\u7684\u5e93\u4e2d\u5f15\u7528\u7684\uff0c\u6211\u4e0d\u80fd\u76f4\u63a5\u79fb\u9664\u4ed6\u4eec\u3002\u5c1d\u8bd5\u8986\u76d6stderr\u7b49\u5b9a\u4e49\u672a\u679c\u4e4b\u540e\uff0c\u6211\u53d1\u73b0\u94fe\u63a5libc\u4e4b\u540e\uff0c\u80fd\u89e3\u51b3\u6807\u51c6\u5e93\u7684\u94fe\u63a5\u5f02\u5e38\uff0c\u4f46\u662f\u751f\u6210\u7684\u53ef\u6267\u884c\u6587\u4ef6\u4f1a\u629b\u51fa\u7a7a\u6307\u9488\u5f02\u5e38\uff0c\u65e0\u6cd5\u8fd0\u884c\u3002\u800c\u4e14\u6211\u6ce8\u610f\u5230x86\u7684\u67b6\u6784\u7f16\u8bd1\u8fc7\u7a0b\u5931\u8d25\u4e86\u3002<\/p>\n\n\n\n<p>\u901a\u8fc7\u8ddf\u8e2a\u65e5\u5fd7\u53d1\u73b0\uff0c\u6784\u5efax86\u65f6\uff0c\u7f16\u8bd1\u5de5\u5177\u94fe\u67e5\u627e\u5931\u8d25\u4e86\uff0c\u662f\u56e0\u4e3ax86\u5de5\u5177\u94fe\u547d\u540d\u548c\u5176\u4ed6\u67b6\u6784\u4e0d\u4e00\u81f4\uff0c\u5bfc\u81f4\u627e\u4e0d\u5230\u7f16\u8bd1\u5668\u3002\u6240\u4ee5\u6211\u5c06cmake\u4fee\u6539\u6210\u5982\u4e0b\u6837\u5f0f\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if (${CMAKE_ANDROID_ARCH_ABI} STREQUAL arm64-v8a)\n        set(CMAKE_CXX_COMPILER ${CMAKE_ANDROID_NDK}toolchains\/llvm\/prebuilt\/linux-x86_64\/bin\/aarch64-linux-android23-clang++)\n    elseif (${CMAKE_ANDROID_ARCH_ABI} STREQUAL armeabi-v7a)\n        set(CMAKE_CXX_COMPILER ${CMAKE_ANDROID_NDK}toolchains\/llvm\/prebuilt\/linux-x86_64\/bin\/armv7a-linux-androideabi23-clang++)\n    elseif (${CMAKE_ANDROID_ARCH_ABI} STREQUAL x86)\n        set(CMAKE_CXX_COMPILER ${CMAKE_ANDROID_NDK}toolchains\/llvm\/prebuilt\/linux-x86_64\/bin\/i686-linux-android23-clang++)\n    elseif (${CMAKE_ANDROID_ARCH_ABI} STREQUAL x86_64)\n        set(CMAKE_CXX_COMPILER ${CMAKE_ANDROID_NDK}toolchains\/llvm\/prebuilt\/linux-x86_64\/bin\/x86_64-linux-android23-clang++)\n    else ()\n        message(FATAL_ERROR \"\u65e0\u6cd5\u89e3\u6790\u7684\u67b6\u6784\uff1a${CMAKE_ANDROID_ARCH_ABI}\")\n    endif ()<\/code><\/pre>\n\n\n\n<p>\u8fd9\u6837\uff0ccmake\u53ef\u4ee5\u9002\u5e94\u6240\u6709\u7684\u76ee\u6807ABI\u3002<\/p>\n\n\n\n<p>\u7136\u540e\uff0c\u6211\u53d1\u73b0\u5728\u6211\u7684\u6784\u5efa\u811a\u672c\u4e2d\uff0c\u901a\u8fc7cmake\u547d\u4ee4\u884c\u53c2\u6570\u6307\u5b9a\u4e86NDK\u8def\u5f84\u548c\u76ee\u6807API\uff0c\u8003\u8651\u5230\u8fd9\u53ef\u80fd\u4f1a\u8986\u76d6CMakeLists.txt\u4e2d\u7684\u8bbe\u7f6e\uff0c\u6211\u5c06\u5b83\u4eec\u4fee\u6539\u6210\u548cCMakeLists.txt\u4e2d\u4e00\u81f4\u4e4b\u540e\uff0c\u6807\u51c6\u5e93\u7684\u94fe\u63a5\u95ee\u9898\u6d88\u5931\u4e86\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u603b\u7ed3<\/h2>\n\n\n\n<p>\u8fc7\u7a0b\u4e2d\u6700\u8be1\u5f02\u7684\u95ee\u9898\u5176\u5b9e\u5c31\u662f\u6700\u540e\u6807\u51c6\u8f93\u5165\u8f93\u51fa\u5e93\u94fe\u63a5\u51fa\u9519\u7684\u95ee\u9898\u3002\u539f\u56e0\u662f\u56e0\u4e3a\u6211\u7f16\u8bd1\u4f9d\u8d56\u9879\u7684\u65f6\u5019\u4f7f\u7528\u7684\u662fNDK r23\uff0c\u76ee\u6807API\u662f23\u3002\u800c\u6784\u5efa\u811a\u672c\u4e2d\u901a\u8fc7\u547d\u4ee4\u884c\u53c2\u6570\u5c06NDK\u6307\u5411\u4e86r21\uff0c\u76ee\u6807API\u4e5f\u88ab\u8986\u5199\u4e3a21\uff0c\u4f4e\u4e8e\u4f9d\u8d56\u9879\u7684\u7248\u672c\uff0c\u5bfc\u81f4\u94fe\u63a5\u51fa\u9519\u3002\u5982\u679c\u5728\u9047\u5230\u6807\u51c6\u5e93\u4e2d\u7684\u5185\u5bb9\u94fe\u63a5\u51fa\u9519\uff0c\u5f88\u6709\u53ef\u80fd\u662f\u4f7f\u7528\u7684\u5de5\u5177\u94fe\u548c\u4f9d\u8d56\u9879\u7684\u5de5\u5177\u94fe\u4e0d\u4e00\u81f4\uff0c\u9700\u8981\u4ed4\u7ec6\u68c0\u67e5\u5404\u9879\u914d\u7f6e\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u51e0\u5929\u524d\uff0c\u6211\u60f3\u8981\u5236\u4f5c\u4e00\u6b3eC++\u5b9e\u73b0\u7684\u540e\u7aef\u4e91\u5bf9\u63a5\u5e93\uff0c\u9884\u8ba1\u5c06\u8981\u5b9e\u73b0Java\u7248\u7c7b\u5e93\u7684\u5b8c\u6574\u529f\u80fd\u3002\u6211\u51c6\u5907\u4f7f\u7528libcurl [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-23","post","type-post","status-publish","format-standard","hentry","category-3"],"_links":{"self":[{"href":"https:\/\/code.lingapi.top\/index.php?rest_route=\/wp\/v2\/posts\/23","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/code.lingapi.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/code.lingapi.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/code.lingapi.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/code.lingapi.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=23"}],"version-history":[{"count":8,"href":"https:\/\/code.lingapi.top\/index.php?rest_route=\/wp\/v2\/posts\/23\/revisions"}],"predecessor-version":[{"id":32,"href":"https:\/\/code.lingapi.top\/index.php?rest_route=\/wp\/v2\/posts\/23\/revisions\/32"}],"wp:attachment":[{"href":"https:\/\/code.lingapi.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=23"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/code.lingapi.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=23"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/code.lingapi.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=23"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}