From 486983d26e226a685868c19966b955384a331e79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Poisson?= Date: Fri, 15 Mar 2019 12:05:08 +0100 Subject: [PATCH] [protobuf_cpp] fixed runtime issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit two issues were causing troubles with protobuf during runtime: - a missing `__init__.py` in site-packages/google was preventing to import the lib (at least with Python 2) - the links options (`-l …`) where not taken into account. By moving them to LDFLAGS it works correctly. --- pythonforandroid/recipes/protobuf_cpp/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pythonforandroid/recipes/protobuf_cpp/__init__.py b/pythonforandroid/recipes/protobuf_cpp/__init__.py index d82fcf7206..30ca030a2a 100644 --- a/pythonforandroid/recipes/protobuf_cpp/__init__.py +++ b/pythonforandroid/recipes/protobuf_cpp/__init__.py @@ -98,6 +98,10 @@ def build_arch(self, arch): # Install python bindings self.install_python_package(arch) + # Create __init__.py which is missing (cf. https://github.com/protocolbuffers/protobuf/issues/1296 + # and https://stackoverflow.com/questions/13862562/google-protocol-buffers-not-found-when-trying-to-freeze-python-app) + open(join(self.ctx.get_site_packages_dir(), 'google', '__init__.py'), 'a').close() + def install_python_package(self, arch): env = self.get_recipe_env(arch) @@ -132,11 +136,10 @@ def get_recipe_env(self, arch): env['CXXFLAGS'] += ' -frtti' env['CXXFLAGS'] += ' -fexceptions' env['LDFLAGS'] += ( + ' -lgnustl_shared -landroid -llog' + ' -L' + self.ctx.ndk_dir + '/sources/cxx-stl/gnu-libstdc++/' + self.ctx.toolchain_version + '/libs/' + arch.arch) - env['LIBS'] = env.get('LIBS', '') + ' -lgnustl_shared -landroid -llog' - return env