NDK: libm static linking
Asked Answered
H

0

9

I have a problem during try to compile sources with recent android-9 x86 platform.

Primary question: why static library libm.a and dynamic libm.so are different?

Problem is i've try to compile:

/path/to/android-ndk-r8/toolchains/x86-4.4.3/prebuilt/linux-x86/bin/i686-android-linux-gcc --sysroot=/path/to/android-ndk-r8/platforms/android-9/arch-x86 -I/path/to/android-ndk-r8/sources/cxx-stl/gnu-libstdc++/include -I/path/to/android-ndk-r8/sources/cxx-stl/gnu-libstdc++/libs/x86/include -L/path/to/android-ndk-r8/sources/cxx-stl/gnu-libstdc++/lib -L/path/to/android-ndk-r8/platforms/android-9/arch-x86/usr/lib -static /path/to/gcc_4_4_6_release/gcc/testsuite/gcc.dg/complex-5.c -std=c99 -O -ffloat-store -o ./complex-5.exe -lm

but I have undefined reference:

/tmp/cc78CsCp.o: In function main': complex-5.c:(.text+0x1a2): undefined reference tofeclearexcept' complex-5.c:(.text+0x1b3): undefined reference to `fetestexcept' collect2: ld returned 1 exit status

pwd: /path/to/android-ndk-r8/platforms/android-9/arch-x86/usr/lib

ls libm* libm.a libm.so

It exists, but if we look with nm for feclearexcept, it isn't present within static library.

Ok, just try to remove -static flag.

/path/to/android-ndk-r8/toolchains/x86-4.4.3/prebuilt/linux-x86/bin/i686-android-linux-gcc --sysroot=/path/to/android-ndk-r8/platforms/android-9/arch-x86 -I/path/to/android-ndk-r8/sources/cxx-stl/gnu-libstdc++/include -I/path/to/android-ndk-r8/sources/cxx-stl/gnu-libstdc++/libs/x86/include -L/path/to/android-ndk-r8/sources/cxx-stl/gnu-libstdc++/lib -L/path/to/android-ndk-r8/platforms/android-9/arch-x86/usr/lib /path/to/gcc_4_4_6_release/gcc/testsuite/gcc.dg/complex-5.c -std=c99 -O -ffloat-store -o ./complex-5.exe -lm

Ok. That the question: why they are differ? I need static linkage, I don't want to force usage of dynamic linkage with -Wl,-Bdynamic -lm. By the way: regular linux libm.a and libm.so contains similar list of functions.

Hygroscope answered 14/6, 2012 at 7:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.