Skip to content

Instantly share code, notes, and snippets.

@geniys
Last active April 25, 2017 00:14
Show Gist options
  • Select an option

  • Save geniys/bb48e6a8ce6e596acd3dabf9e671af65 to your computer and use it in GitHub Desktop.

Select an option

Save geniys/bb48e6a8ce6e596acd3dabf9e671af65 to your computer and use it in GitHub Desktop.

Revisions

  1. geniys revised this gist Apr 25, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion use_boost_at_android.md
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@ $NDK/build/tools/make_standalone_toolchain.py \
    --arch arm --api 21 --install-dir /tmp/my-android-toolchain
    ```

    > You can get detail information from [https://developer.android.com/ndk/guides/standalone_toolchain.html](https://developer.android.com/ndk/guides/standalone_toolchain.html)
    > You can get detail information from https://developer.android.com/ndk/guides/standalone_toolchain.html
    # Build boost
    1. Download boost library and extract anywhere
  2. geniys revised this gist Apr 25, 2017. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion use_boost_at_android.md
    Original file line number Diff line number Diff line change
    @@ -62,4 +62,8 @@ android {
    # Environment
    * Ubuntu 16.04
    * NDK r14b
    * Boost 1.64.0
    * Boost 1.64.0

    # Reference
    * https://developer.android.com/ndk/guides/cpp-support.html
    * https://developer.android.com/ndk/guides/standalone_toolchain.html
  3. geniys revised this gist Apr 25, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion use_boost_at_android.md
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@ $NDK/build/tools/make_standalone_toolchain.py \
    # Build boost
    1. Download boost library and extract anywhere
    2. run ./bootstrap.sh (not cross-compile)
    3. run ./b2 --prefix=/tmp/my-boot-library toolset=clang target-os=android install
    3. run ./b2 --prefix=/tmp/my-boot-library toolset=clang target-os=android install (cross-compile)

    > If you do not want symbolic link, modify `rule tag` funtion at `boostcpp.jam` file
  4. geniys revised this gist Apr 25, 2017. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion use_boost_at_android.md
    Original file line number Diff line number Diff line change
    @@ -58,4 +58,8 @@ android {
    // }
    // }
    }
    ```
    ```
    # Environment
    * Ubuntu 16.04
    * NDK r14b
    * Boost 1.64.0
  5. geniys renamed this gist Apr 25, 2017. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  6. geniys created this gist Apr 25, 2017.
    61 changes: 61 additions & 0 deletions use_boost_at_android.mk
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,61 @@
    # Make a standalone toolchain
    1. Download NDK and extract anywhere
    2. get toolchain
    ```
    $NDK/build/tools/make_standalone_toolchain.py \
    --arch arm --api 21 --install-dir /tmp/my-android-toolchain
    ```

    > You can get detail information from [https://developer.android.com/ndk/guides/standalone_toolchain.html](https://developer.android.com/ndk/guides/standalone_toolchain.html)

    # Build boost
    1. Download boost library and extract anywhere
    2. run ./bootstrap.sh (not cross-compile)
    3. run ./b2 --prefix=/tmp/my-boot-library toolset=clang target-os=android install

    > If you do not want symbolic link, modify `rule tag` funtion at `boostcpp.jam` file

    # Add to Android project
    ## CMakeLists.txt
    ```
    include_directories( /tmp/my-boot-library/include/ )

    add_library(boost STATIC IMPORTED)
    set_target_properties(boost PROPERTIES IMPORTED_LOCATION /tmp/my-boot-library/lib/libboost_system.a)

    # add_library(boost SHARED IMPORTED)
    # set_target_properties(boost PROPERTIES IMPORTED_LOCATION /tmp/my-boot-library/lib/libboost_system.so)

    target_link_libraries( # Specifies the target library.
    native-lib

    # Links the target library to the log library
    # included in the NDK.
    ${log-lib}

    boost)
    ```
    ## Build.gradle(Module:app)
    ```
    android {
    ...
    defaultConfig {
    ...
    externalNativeBuild {
    cmake {
    cppFlags "-std=c++11 -frtti -fexceptions"

    abiFilters 'armeabi'

    arguments '-DANDROID_STL=c++_static'
    }
    }
    }
    // shared library case
    // sourceSets {
    // main {
    // jniLibs.srcDirs = ['/tmp/my-boot-library/lib/']
    // }
    // }
    }
    ```