我在尝试使用最新的 android-9 x86 平台编译源代码时遇到问题。
主要问题:为什么是静态库libm.a和动态的libm.so是不同的?
问题是我尝试编译:
/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
但我有未定义的参考:
/tmp/cc78CsCp.o:功能中main': complex-5.c:(.text+0x1a2):
undefined reference to
feclearexcept'complex-5.c:(.text+0x1b3):
对“fetestexcept”collect2 的未定义引用:ld 返回 1 退出
地位
密码:/path/to/android-ndk-r8/platforms/android-9/arch-x86/usr/lib
ls libm*
libm.a libm.so
它存在,但是如果我们用 nm 来查找费克利尔除外,它不存在于静态库中。
好的,只需尝试删除 -static 标志即可。
/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 -流明
好的。问题是:为什么它们不同?我需要静态链接,我不想强制使用动态链接-Wl,-B动态-lm。顺便说一下:常规的 linux libm.a 和 libm.so 包含类似的函数列表。
None
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)