kivy / python-for-android

Turn your Python application into an Android APK
https://python-for-android.readthedocs.io
MIT License
8.33k stars 1.84k forks source link

gRPC Recipe Error #2498

Closed ghost closed 2 months ago

ghost commented 3 years ago

Hi everyone,

I continue the issue described here: https://github.com/kivy/python-for-android/issues/1052 . The idea is to create a gRPC recipe for p4a.

I tried to fork the existing recipe, https://github.com/hpsaturn/p4a_grpc_recipe/blob/master/__init__.py. The recipe there was built inside the docker container, and all the dependencies were also installed separately. In my fork https://github.com/Splato/p4a_grpc_recipe/edit/master/__init__.py I install all dependencies as 'modules' (code lines 129-133) except for the openssl package (grpc installs BoringSSL that fails in p4a). However, I get the following error after compiling 60% of the recipe:

[ 60%] Linking CXX shared library libgrpc_plugin_support.so
CMakeFiles/grpc_plugin_support.dir/src/compiler/python_generator.cc.o: In function `PythonGrpcGenerator':
~/.buildozer/android/platform/build-arm64-v8a/build/other_builds/grpcio/arm64-v8a__ndk_target_21/grpcio/grpc/src/compiler/python_generator.cc:829: undefined reference to `google::protobuf::compiler::CodeGenerator::~CodeGenerator()'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [CMakeFiles/grpc_plugin_support.dir/build.make:175: libgrpc_plugin_support.so] Error 1
make[1]: *** [CMakeFiles/Makefile2:894: CMakeFiles/grpc_plugin_support.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

Then I also tried to include protobuf as dependencies in the grpc recipe (the recipe protobuf_cpp https://github.com/kivy/python-for-android/blob/master/pythonforandroid/recipes/protobuf_cpp/__init__.py). Then I changed the protobuf to 'package' (129) and the path to libraries and executables in cmake (lines 112-115). However, then I got another error:

-- Looking for __system_property_get - found
CMake Error at /usr/share/cmake-3.16/Modules/FindProtobuf.cmake:469 (file):
  file STRINGS file "/opt/install/include/google/protobuf/stubs/common.h"
  cannot be read.
Call Stack (most recent call first):
  cmake/protobuf.cmake:58 (find_package)
  CMakeLists.txt:261 (include)

CMake Error at /usr/share/cmake-3.16/Modules/FindProtobuf.cmake:475 (math):
  math cannot parse the expression: " / 1000000": syntax error, unexpected
  exp_DIVIDE (2).
Call Stack (most recent call first):
  cmake/protobuf.cmake:58 (find_package)
  CMakeLists.txt:261 (include)

CMake Error at /usr/share/cmake-3.16/Modules/FindProtobuf.cmake:476 (math):
  math cannot parse the expression: " / 1000 % 1000": syntax error,
  unexpected exp_DIVIDE (2).
Call Stack (most recent call first):
  cmake/protobuf.cmake:58 (find_package)
  CMakeLists.txt:261 (include)

CMake Error at /usr/share/cmake-3.16/Modules/FindProtobuf.cmake:477 (math):
  math cannot parse the expression: " % 1000": syntax error, unexpected
  exp_MOD (2).
Call Stack (most recent call first):
  cmake/protobuf.cmake:58 (find_package)
  CMakeLists.txt:261 (include)

-- Found Protobuf: /opt/install/lib/libprotobuf.a (found version "ERROR.ERROR.ERROR") 
-- Found OpenSSL: ~/.buildozer/android/platform/build-arm64-v8a/build/other_builds/openssl/arm64-v8a__ndk_target_21/openssl1.1/libcrypto.so (found version "1.1.1k")  
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of off64_t
-- Check size of off64_t - done
-- Looking for fseeko
-- Looking for fseeko - found
-- Looking for unistd.h
-- Looking for unistd.h - found
-- Renaming
--     ~/.buildozer/android/platform/build-arm64-v8a/build/other_builds/grpcio/arm64-v8a__ndk_target_21/grpcio/grpc/third_party/zlib/zconf.h
-- to 'zconf.h.included' because this file is included with zlib
-- but CMake generates it automatically in the build directory.
-- Configuring incomplete, errors occurred!
See also "~/.buildozer/android/platform/build-arm64-v8a/build/other_builds/grpcio/arm64-v8a__ndk_target_21/grpcio/grpc/build/CMakeFiles/CMakeOutput.log".
See also "~/.buildozer/android/platform/build-arm64-v8a/build/other_builds/grpcio/arm64-v8a__ndk_target_21/grpcio/grpc/build/CMakeFiles/CMakeError.log".

So I guess at this point, I need some help with configuring the protobuf installation. Thanks.

sergeplatonov commented 2 years ago

After specifying the correct path to libprotobuf.so and libprotoc.so (-DProtobuf_PROTOC_EXECUTABLE,.Dprotobuf_LIBRARIES',' DProtobuf_PROTOC_LIBRARY','-DProtobuf_INCLUDE_DIR',) I removed these errors. Now the recipe is compiled to 99%, but in the end I get the following errors:

[ 95%] Linking CXX executable gen_hpack_tables
/home/sergey/.buildozer/android/platform/android-ndk-r19c/toolchains/llvm/prebuilt/linux-x86_64/lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: warning: libpython3.8.so, needed by /home/sergey/Desktop/project/.buildozer/android/platform/build-arm64-v8a/build/other_builds/protobuf/arm64-v8a__ndk_target_24/protobuf/src/.libs/libprotobuf.so, not found (try using -rpath or -rpath-link)
/home/sergey/.buildozer/android/platform/android-ndk-r19c/toolchains/llvm/prebuilt/linux-x86_64/lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: warning: libz.so, needed by /home/sergey/Desktop/project/.buildozer/android/platform/build-arm64-v8a/build/other_builds/protobuf/arm64-v8a__ndk_target_24/protobuf/src/.libs/libprotobuf.so, not found (try using -rpath or -rpath-link)
/home/sergey/.buildozer/android/platform/android-ndk-r19c/toolchains/llvm/prebuilt/linux-x86_64/lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: warning: libc++_shared.so, needed by /home/sergey/Desktop/project/.buildozer/android/platform/build-arm64-v8a/build/other_builds/protobuf/arm64-v8a__ndk_target_24/protobuf/src/.libs/libprotobuf.so, not found (try using -rpath or -rpath-link)
/home/sergey/.buildozer/android/platform/android-ndk-r19c/toolchains/llvm/prebuilt/linux-x86_64/lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: warning: libstdc++.so, needed by /home/sergey/Desktop/project/.buildozer/android/platform/build-arm64-v8a/build/other_builds/protobuf/arm64-v8a__ndk_target_24/protobuf/src/.libs/libprotobuf.so, not found (try using -rpath or -rpath-link)
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [CMakeFiles/gen_hpack_tables.dir/build.make:151: gen_hpack_tables] Error 1
make[1]: *** [CMakeFiles/Makefile2:1569: CMakeFiles/gen_hpack_tables.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

I tried already to add these dependencies to LDFLAGS and CXXFLAGS in the environment, specify them in -DCMAKE_INSTALL_PREFIX and -DCMAKE_FIND_ROOT_PATH in the cmake, change -DCMAKE_SHARED_LINKER_FLAGS and -DCMAKE_EXE_LINKER_FLAGS. All these ideas unfortunately don't work. Somehow the libprotobuf.so file compiled with the protobuf recipe cannot find the c++share and python libraries. Perhaps anyone has an idea what else can I try to solve it. Thanks!

Duke0425 commented 2 years ago

i was the same error, who can tell us about grpcio recipes problem

rEHui-MbIcJIu commented 1 year ago

any suggestions? Found this: https://github.com/grpc/grpc/blob/master/setup.py

But i dont know how to use it yet