Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
May 8, 2020

Conversation

pthom
Copy link
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

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 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
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
Contributor

@smzahraee Could you test this PR?

Thanks.

@pthom
Copy link
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
Contributor

LGTM.

@JackBoosY JackBoosY added the info:reviewed Pull Request changes follow basic guidelines label May 8, 2020
@strega-nil
Copy link
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:reviewed Pull Request changes follow basic guidelines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[protobuf]ubuntu-android build failure
4 participants