Skip to content

Commit e0c67cf

Browse files
committed
[[ Bug 19931 ]] Statically link libstdc++ in Android shared libs
Since we statically link libstdc++ in the main Android executable now, symbols in libstdc++ not used by it get stripped. So, dlopen fails on shared libraries that use any symbols in libstdc++ which are not used by (and therefore are stripped from) the main executable. This patch ensures that shared libraries statically link libstdc++ themselves so that they have the required symbols. Additionally, the sqlite driver needs the math library, so statically link to libm.
1 parent 9f71832 commit e0c67cf

File tree

4 files changed

+19
-0
lines changed

4 files changed

+19
-0
lines changed

config/android-settings.gypi

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
'variables':
33
{
44
'c++_std': '<!(echo ${CXX_STD:-c++11})',
5+
'android_lib_path%': '<!(echo ${ANDROID_LIB_PATH})',
56
},
67

78
'cflags':
@@ -30,6 +31,17 @@
3031

3132
'target_conditions':
3233
[
34+
[
35+
'_type == "loadable_module"',
36+
{
37+
'ldflags':
38+
[
39+
'-L<(android_lib_path)',
40+
'-lstdc++',
41+
],
42+
43+
},
44+
],
3345
[
3446
'silence_warnings == 0',
3547
{

docs/development/build-android.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,12 @@ ANDROID_PLATFORM=android-17
8989
ANDROID_NDK=${TOOLCHAIN}/android-ndk-r14
9090
ANDROID_SDK=${TOOLCHAIN}/android-sdk-linux
9191
ANDROID_BUILD_TOOLS=25.0.2
92+
ANDROID_LIB_PATH=${TOOLCHAIN}/standalone/${TRIPLE}/lib
9293

9394
export JAVA_SDK
9495
export CC CXX LINK AR
9596
export ANDROID_PLATFORM ANDROID_NDK ANDROID_SDK ANDROID_BUILD_TOOLS
97+
export ANDROID_LIB_PATH
9698
````
9799

98100
### Generating makefiles

docs/notes/bugfix-19931.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Fix loading of shared libraries on Android

revdb/revdb.gyp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,10 @@
488488
# Error in ../../thirdparty/libsqlite/include/qry_dat.h
489489
'-Werror=return-type',
490490
],
491+
'libraries':
492+
[
493+
'-lm',
494+
],
491495
},
492496
],
493497
[

0 commit comments

Comments
 (0)