8000 [protobuf_cpp] fixed runtime issues · ashang/python-for-android@486983d · GitHub
[go: up one dir, main page]

Skip to content

Commit 486983d

Browse files
committed
[protobuf_cpp] fixed runtime issues
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.
1 parent 84142eb commit 486983d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

pythonforandroid/recipes/protobuf_cpp/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ def build_arch(self, arch):
9898
# Install python bindings
9999
self.install_python_package(arch)
100100

101+
# Create __init__.py which is missing (cf. https://github.com/protocolbuffers/protobuf/issues/1296
102+
# and https://stackoverflow.com/questions/13862562/google-protocol-buffers-not-found-when-trying-to-freeze-python-app)
103+
open(join(self.ctx.get_site_packages_dir(), 'google', '__init__.py'), 'a').close()
104+
101105
def install_python_package(self, arch):
102106
env = self.get_recipe_env(arch)
103107

@@ -132,11 +136,10 @@ def get_recipe_env(self, arch):
132136
env['CXXFLAGS'] += ' -frtti'
133137
env['CXXFLAGS'] += ' -fexceptions'
134138
env['LDFLAGS'] += (
139+
' -lgnustl_shared -landroid -llog' +
135140
' -L' + self.ctx.ndk_dir +
136141
'/sources/cxx-stl/gnu-libstdc++/' + self.ctx.toolchain_version +
137142
'/libs/' + arch.arch)
138-
env['LIBS'] = env.get('LIBS', '') + ' -lgnustl_shared -landroid -llog'
139-
140143
return env
141144

142145

0 commit comments

Comments
 (0)
0