Skip to content

Commit 7df3a43

Browse files
committed
fix netifaces to correctly link and therefore detect the symbol for socket
1 parent 0335c93 commit 7df3a43

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

pythonforandroid/recipes/netifaces/__init__.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import os
12
from pythonforandroid.recipe import CompiledComponentsPythonRecipe
23

3-
44
class NetifacesRecipe(CompiledComponentsPythonRecipe):
55

66
version = '0.10.4'
@@ -16,11 +16,19 @@ class NetifacesRecipe(CompiledComponentsPythonRecipe):
1616
def get_recipe_env(self, arch):
1717
env = super(NetifacesRecipe, self).get_recipe_env(arch)
1818
env['PYTHON_ROOT'] = self.ctx.get_python_install_dir()
19-
env['CFLAGS'] += ' -I' + env['PYTHON_ROOT'] + '/include/python2.7'
20-
# Set linker to use the correct gcc
19+
env['CFLAGS'] += ' -I{}'.format(self.ctx.python_recipe.include_root(arch.arch))
2120
env['LDSHARED'] = env['CC'] + ' -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions'
22-
env['LDFLAGS'] += ' -L' + env['PYTHON_ROOT'] + '/lib' + \
23-
' -lpython2.7'
21+
22+
# required for libc and libdl
23+
ndk_dir = self.ctx.ndk_platform
24+
ndk_lib_dir = os.path.join(ndk_dir, 'usr', 'lib')
25+
env['LDFLAGS'] += ' -L{}'.format(ndk_lib_dir)
26+
env['LDFLAGS'] += ' -L{}'.format(self.ctx.python_recipe.link_root(arch.arch))
27+
env['LDFLAGS'] += ' -lpython{}'.format(self.ctx.python_recipe.major_minor_version_string)
28+
if 'python3' in self.ctx.python_recipe.name:
29+
env['LDFLAGS'] += 'm'
30+
# XX very very bad, but in their setup, conftest doesn't use LDFLAGS?
31+
env['CC'] += env['LDFLAGS']
2432
return env
2533

2634

0 commit comments

Comments
 (0)