1

I am fairly new to this. So, I am trying to cross compile GRPC (https://github.com/grpc/grpc) for android using cmake and NDK toolchain to generate shared libraries, using the below:

cmake -DCMAKE_TOOLCHAIN_FILE=$And_PATH/android.toolchain.cmake -DCMAKE_CROSSCOMPILING=true -DANDROID_ABI=arm64-v8a -DCMAKE_INSTALL_PREFIX=/cross_grpc -DANDROID_PLATFORM=android-26 -DANDROID_STL=c++_shared CFLAGS="std=c11" CXXFLAGS="std=c++14" cmake -B . -S /grpc

With the above i am able to build and static libraries get generated, but if i add -DBUILD_SHARED_LIBS=ON , i am getting below errors

ld: error: undefined symbol: BIO_ctrl referenced by bio_ssl.cc:191 (/grpc/third_party/boringssl-with-bazel/src/ssl/bio_ssl.cc:191)

ld: error: undefined symbol: BIO_clear_retry_flags referenced by bio_ssl.cc:65 (/grpc/third_party/boringssl-with-bazel/src/ssl/bio_ssl.cc:65)

ld: error: undefined symbol: BIO_set_retry_write referenced by bio_ssl.cc:71 (/grpc/third_party/boringssl-with-bazel/src/ssl/bio_ssl.cc:71)

I have not pasted all the errors as it's a long list of undefined symbol errors.

2

1 Answer 1

0

So, I was able to cross compile it. Below cmake command I used. Make sure to play around the flag according to your situation.

-> git clone https://github.com/grpc/grpc

-> cd grpc

-> git submodule update --init

-> mkdir cross_grpc && cd cross_grpc

cmake -DCMAKE_TOOLCHAIN_FILE=/Android/Sdk/ndk/25.1.8937393/build/cmake/android.toolchain.cmake -DCMAKE_CROSSCOMPILING=true -DANDROID_ABI=arm64-v8a -DCMAKE_INSTALL_PREFIX=/cross_grpc -DANDROID_PLATFORM=android-26 -DCMAKE_BUILD_TYPE=Release -DANDROID_STL=c++_shared CFLAGS="std=c11 -Wl -export-dynamic" CXXFLAGS="std=c++14 -Wl -export-dynamic" -DCMAKE_BUILD_TYPE=Release -DOPENSSL_ROOT_DIR=/etc/ssl/ -B . -S /grpc

make "-j4" install
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.