首页 > 代码库 > 为android编译libsocket的脚本
为android编译libsocket的脚本
#!/bin/bash
U32=0 #编译64位arm时 U32=0 编译32位arm时 U32=1 其他参数不需要变动
TARGET=android-24
HOST=darwin-x86_64
TOOL=aarch64-linux-android #arm-linux-androideabi aarch64-linux-android
ARCH=arch-arm64 #arch-arm arch-arm64
if [ $U32 -ne 0 ]; then
echo "32位arm"
TOOL=arm-linux-androideabi
ARCH=arch-arm
fi
TOOLCHAIN=$TOOL-4.9
export NDK_ROOT=/Users/musictom/Library/Android/sdk/ndk-bundle/
export SYSROOT="$NDK_ROOT/platforms/$TARGET/$ARCH"
export CPPFLAGS="-I$NDK_ROOT/platforms/$TARGET/$ARCH/usr/include -I$NDK_ROOT/toolchains/$TOOLCHAIN/prebuilt/$HOST/user/include"
export LDFLAGS="-L$NDK_ROOT/platforms/$TARGET/$ARCH/usr/lib --sysroot=$SYSROOT"
rm -f *.so *.o
$NDK_ROOT/toolchains/$TOOLCHAIN/prebuilt/$HOST/bin/$TOOL-gcc -Wall -fPIC -O2 -c ../c/inet/libinetsocket.c $CPPFLAGS
$NDK_ROOT/toolchains/$TOOLCHAIN/prebuilt/$HOST/bin/$TOOL-gcc -Wall -fPIC -O2 -c ../c/unix/libunixsocket.c $CPPFLAGS
$NDK_ROOT/toolchains/$TOOLCHAIN/prebuilt/$HOST/bin/$TOOL-gcc -shared -o libsocket.so libinetsocket.o libunixsocket.o $LDFLAGS
rm -f *.o
cp *.so $NDK_ROOT/toolchains/$TOOLCHAIN/prebuilt/$HOST/user/lib/
mkdir $NDK_ROOT/toolchains/$TOOLCHAIN/prebuilt/$HOST/user/include/socket
cp ../headers/*.hpp $NDK_ROOT/toolchains/$TOOLCHAIN/prebuilt/$HOST/user/include/socket/
cp ../headers/*.h $NDK_ROOT/toolchains/$TOOLCHAIN/prebuilt/$HOST/user/include/socket/
参考https://github.com/gcesarmza/curl-android-ios/blob/master/curl-compile-scripts/build_Android.sh
为android编译libsocket的脚本
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。