Skip to content

[protobuf] Correct protobuf under android (Fix issue #8218)#11228

Merged
strega-nil merged 2 commits intomicrosoft:masterfrom
pthom:fix_protobuf_android
May 8, 2020
Merged

[protobuf] Correct protobuf under android (Fix issue #8218)#11228
strega-nil merged 2 commits intomicrosoft:masterfrom
pthom:fix_protobuf_android

Conversation

@pthom
Copy link
Copy Markdown
Contributor

@pthom pthom commented May 7, 2020

Describe the pull request
This PR fixes and issue for protobuf when building for Android.
When linking, an error "undefined reference to '__android_log_write' was happening.

The original error is likely inside protobuf CMakeLists, which should link the log library under Android: see this issue in protobuf repo

This fixes #8218

  • Which triplets are supported/not supported?
    There is no official Android triplet at the moment. I will add an example triplet below.

  • Have you updated the CI baseline?
    No

  • Does your PR follow the maintainer guide?
    Yes


There is no official android triplet file. So, I provide an example one below. May be it could be an inspiration for a triplet in the community folder (however I am not an android expert).

Steps to reproduce the build

  1. Use this triplet file:

triplets/android-armeabi-v7a.cmake

set(VCPKG_TARGET_ARCHITECTURE arm)
set(VCPKG_CRT_LINKAGE static)
set(VCPKG_LIBRARY_LINKAGE dynamic)
set(VCPKG_CMAKE_SYSTEM_NAME Android)

set(ANDROID_NDK_HOME $ENV{ANDROID_NDK_HOME})
if ("${ANDROID_NDK_HOME}" MATCHES "^$")
  message(FATAL_ERROR 
    "Please set an env variable ANDROID_NDK_HOME pointing to your ndk-bundle folder. 
    For example: export ANDROID_NDK_HOME=/home/your-account/Android/Sdk/ndk-bundle")
endif()
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE ${ANDROID_NDK_HOME}/build/cmake/android.toolchain.cmake)

set(ANDROID_ABI armeabi-v7a)
# ANDROID_ABI can be : "armeabi-v7a" , "armeabi-v7a with NEON", "arm64-v8a", "x86" or "x86_64"
  1. Download and install the android ndk-bundle

  2. Set an env var to the ndk-bundle folder

    export ANDROID_NDK_HOME=/home/your-account/Android/Sdk/ndk-bundle
  1. Build the protobuf package
    ./vcpkg install "protobuf:android-armeabi-v7a"

@msftclas
Copy link
Copy Markdown

msftclas commented May 7, 2020

CLA assistant check
All CLA requirements met.

- This fixes microsoft#8218

The original error is linkely inside protobuf CMakeLists, which should
link the log library under Android.
See explanations here:
protocolbuffers/protobuf#2719
@pthom pthom force-pushed the fix_protobuf_android branch from 194172d to c7a466a Compare May 7, 2020 19:55
@pthom pthom marked this pull request as ready for review May 7, 2020 19:56
@LilyWangL LilyWangL changed the title Correct protobuf under android (Fix issue #8218) [protobuf] Correct protobuf under android (Fix issue #8218) May 8, 2020
@LilyWangL LilyWangL requested a review from JackBoosY May 8, 2020 02:05
Copy link
Copy Markdown
Contributor

@JackBoosY JackBoosY left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the version info. See documentation.

@JackBoosY
Copy link
Copy Markdown
Contributor

@smzahraee Could you test this PR?

Thanks.

@pthom
Copy link
Copy Markdown
Contributor Author

pthom commented May 8, 2020

Please update the version info. See documentation.

Done, I switched from 3.11.4 to 3.11.4-1

@JackBoosY
Copy link
Copy Markdown
Contributor

LGTM.

@JackBoosY JackBoosY added the info:needs-maintainer-attention Lets the current 'on rotation' vcpkg maintainer know they need to look at this. label May 8, 2020
@strega-nil
Copy link
Copy Markdown
Contributor

LGTM, thanks @pthom :)

@strega-nil strega-nil merged commit fcdac2d into microsoft:master May 8, 2020
@pthom pthom deleted the fix_protobuf_android branch February 7, 2022 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

info:needs-maintainer-attention Lets the current 'on rotation' vcpkg maintainer know they need to look at this.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[protobuf]ubuntu-android build failure

4 participants