码迷,mamicode.com
首页 > 移动开发 > 详细

为android编译libsocket的脚本

时间:2017-04-09 16:23:50      阅读:304      评论:0      收藏:0      [点我收藏+]

标签:需要   shared   xsocket   -shared   cpp   ast   rip   tool   header   

#!/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的脚本

标签:需要   shared   xsocket   -shared   cpp   ast   rip   tool   header   

原文地址:http://www.cnblogs.com/yuanxiaoping_21cn_com/p/6685080.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!