zoukankan      html  css  js  c++  java
  • windows下编译Android版本的boost库文件

    1.起因:

    手上有一个用到了boost的asio库和thread库的工程要编译到手机上(Android版本和ios版本),本文只介绍如何编译到Android版本,ios版本之后再介绍,也许就不介绍了(注:因为mac下官方有教程如何编译)

    2.准备工作

    2.1 下载boost库,我这里用到的是1.58.0

    2.2 下载NDK(注:Google官方地址,需要FQ),根据情况自己选择下载版本,我这里用的是android-ndk-r10d-windows-x86_64.exe

    2.3 安装visual studio 2012或者2013, 我用的是vs2013

    3.开始编译

    3.1 解压boost压缩文件

    3.2 在命令行下进入上步文件夹下,然后运行bootstrap.bat,这里会生成project-config.jam文件

    3.3 修改project-config.jam文件,修改内容如下

    import option ;
    
    androidNDKRoot = E:/android/android-ndk-r10d ; # put the relevant path
    using gcc : android 
    : 
    $(androidNDKRoot)/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/bin/arm-linux-androideabi-g++ 
    :
    <archiver>$(androidNDKRoot)/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/bin/arm-linux-androideabi-ar
    <compileflags>-fexceptions
    <compileflags>-frtti
    <compileflags>-fpic
    <compileflags>-ffunction-sections
    <compileflags>-funwind-tables
    <compileflags>-D__ARM_ARCH_5__
    <compileflags>-D__ARM_ARCH_5T__
    <compileflags>-D__ARM_ARCH_5E__
    <compileflags>-D__ARM_ARCH_5TE__
    <compileflags>-Wno-psabi
    <compileflags>-march=armv5te
    <compileflags>-mtune=xscale
    <compileflags>-msoft-float
    <compileflags>-mthumb
    <compileflags>-Os
    <compileflags>-std=c++11
    <compileflags>-fomit-frame-pointer
    <compileflags>-fno-strict-aliasing
    <compileflags>-finline-limit=64
    <compileflags>-I$(androidNDKRoot)/platforms/android-9/arch-arm/usr/include
    <compileflags>-Wa,--noexecstack
    <compileflags>-DANDROID
    <compileflags>-D__ANDROID__
    <compileflags>-DNDEBUG
    <compileflags>-O2
    <compileflags>-g
    <compileflags>-I$(androidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.9/include
    <compileflags>-I$(androidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi/include
    # @Moss - Above are the 'oficial' android flags
    <architecture>arm
    <compileflags>-fvisibility=hidden
    <compileflags>-fvisibility-inlines-hidden
    <compileflags>-fdata-sections
    <cxxflags>-D__arm__
    <cxxflags>-D_REENTRANT
    <cxxflags>-D_GLIBCXX__PTHREADS
    ;
     
    option.set keep-going : false ; 
     
    

    3.4 创建批处理命令,内容如下

    b2 --without-context --without-coroutine --without-program_options --without-container --without-iostreams --without-locale --without-signals --without-wave --without-timer --without-mpi --without-log --without-test --without-atomic --without-chrono --without-filesystem --without-graph --without-graph_parallel --without-math --without-python --without-random link=static threading=multi threadapi=pthread target-os=linux toolset=gcc-android
    

    b2 参数说明

    • --without 表示不编译这个项目
    • --with 表示要编译这个项目

    3.5 运行3.4创建的批处理,应该就能生成静态库文件,可以在项目中使用了

    后记:如果还是有问题,详细查看我之前的步骤,欢迎大家来和我讨论

  • 相关阅读:
    Minecraft我的世界如何联机
    关于我的博客地址jvav的由来
    ThreadLocal使用
    使用免费tk域名
    MVC的request,response流程
    TiDB原理与集群架构
    net5 自定义 中间件
    net5 Autofac支持
    net5 Autofac 支持AOP (1)
    mysql 索引优化
  • 原文地址:https://www.cnblogs.com/zjzyh/p/4643855.html
Copyright © 2011-2022 走看看