Android的NDK R5B外部构建和supc ++链接问题 [英] Android NDK r5b external build and supc++ link problem

查看:1249
本文介绍了Android的NDK R5B外部构建和supc ++链接问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图交叉编译我们的C ++ code座(使用CMake的)使用NDK R5B在Ubuntu 10.10的Andr​​oid平台。编译阶段成功,期间的最后链接阶段不过。所以也有到是在libsupc ++一个文件(我指定链接)符号的许多悬而未决的引用。我也曾尝试-lsupc ++没什么区别。

I am attempting to cross-compile our C++ code base (using CMake) for the Android platform using the r5b NDK on Ubuntu 10.10. The compile phase succeeds, however during the final link phase for the .so there are many unresolved references to symbols that are in the libsupc++.a file (which I specify to link in). I have also tried -lsupc++ with no difference.

我试图为紧跟命令行可以通过官方NDK构建系统建设试验gnustl-1 NDK的测试应用程序的时候产生的。

I tried to follow the command-line as closely as possible as generated by the official ndk-build system when building the test-gnustl-1 NDK test app.

运行在臂Linux的androideabi纳米工具臂Linux的androideabi / lib目录/ libsupc ++一个文件显示在错误输出中引用的符号定义(T)。

Running the arm-linux-androideabi-nm tool on the arm-linux-androideabi/lib/libsupc++.a file shows the symbols as defined (T) referenced in the error output.

在libsupc ++无法找到定义的符号的一个例子是: __ gxx_personality_v0

An example of a symbol defined in libsupc++ it cannot find is: __gxx_personality_v0

下面是我的样本连接线和导致错误的样本。

Here is my sample link line and a resulting sample of errors.

<$c$c>/home/user/android-ndk-r5b/toolchains/arm-linux-androideabi-4.4.3/$p$pbuilt/linux-x86/bin/arm-linux-androideabi-g++ -fPIC -Wall -Wextra -Wno-未使用-Wno-multichar -fno-RTTI -MMD -MP -MF -ffunction截面-fexceptions -funwind桌-Wno-psabi -march =的ARMv5TE -mtune =的XScale -msoft浮动-mthumb -fomit-frame-pointer的-fno严格混叠-finline限制= 64 -Wa, - noexecstack -DANDROID -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -O0 -DDEBUG -D_DEBUG -g --sysroot = /家庭/用户/ Android的NDK-R5B /平台/ Android的9 /弓臂轮候册, - GC-部分-Wl,-z,nocopyreloc轮候册, - 没有定义,-z,noexecstack -L /家庭/用户/ Android的NDK-R5B /平台/ Android的9 /弓臂/ usr / lib目录-L/home/user/android-ndk-r5b/toolchains/arm-linux-androideabi-4.4.3/$p$pbuilt/linux-x86/arm-linux-androideabi/lib -Wl,-rpath链接= / home / user中/ Android的NDK-R5B /平台/ Android的9 /弓臂/ usr / lib目录的/ home /用户/ Android的NDK-R5B /来源/ CXX-STL / GNU -libstdc ++ /库/ armeabi /的libstdc ++。一个-lc -lsupc ++ -shared -o ../../lib/Debug/libFoo.so CMakeFiles / Foo.dir / Foo.co CMakeFiles / Foo.dir / Bar.cpp。 ØCMakeFiles / Foo.dir / Baz.cpp.o

`CMakeFiles/Foo.dir/Foo.cpp.o: In function 'myFunc':
/home/user/myroj/src/native/modules/libFoo/Foo.cpp:292: undefined reference to '__cxa_end_cleanup'
CMakeFiles/Foo.dir/Foo.cpp.o:(.ARM.extab.text.myFunc+0x0): undefined reference to '__gxx_personality_v0'
...
/home/user/android-ndk-r5b/toolchains/android/sources/cxx-stl/gnu-libstdc++/include/bits/vector.tcc:350: undefined reference to '__cxa_begin_catch'
/home/user/android-ndk-r5b/toolchains/android/sources/cxx-stl/gnu-libstdc++/include/bits/vector.tcc:357: undefined reference to '__cxa_rethrow'
/home/user/android-ndk-r5b/toolchains/android/sources/cxx-stl/gnu-libstdc++/include/bits/stl_vector.h:1153: undefined reference to 'std::__throw_length_error(char const*)'
/home/user/android-ndk-r5b/toolchains/android/sources/cxx-stl/gnu-libstdc++/include/bits/stl_tree.h:199: undefined reference to 'std::_Rb_tree_decrement(std::_Rb_tree_node_base*)'
...

我试图创建一个简单的hello-world应用程序,使使用异常和链接在一个简单的某文件。我得到了同样的错误,直到我在libsupc ++链接。库,而不是直接使用-lsupc ++。然而,同样的技术并没有在较大的项目链接步骤工作。 NDK的文档也建议-lsupc ++'应该是使用外部构建工具时使用。

I tried to creating a simple hello-world app that makes use of exceptions and links in a simple .a file. I got the same errors until I linked in the libsupc++.a library directly instead of using '-lsupc++'. However, this same technique did not work on the larger project link step. The NDK docs also suggest '-lsupc++' is should be used when using external build tools.

我出关于如何解决此问题的链接想法。我试图重新排序的链接线一样,我能想到的方法很多。我知道一般的连接可以是一个善变的过程。
任何帮助是极大的AP preciated。

I am out of ideas on how to resolve this linking issue. I have tried reordering the link line as many ways as I could think of. I know linking in general can be a fickle process. Any help is greatly appreciated.

推荐答案

原来我需要添加 -L / home / user中/ Android的NDK-R5B /来源/ CXX-STL / GNU -libstdc ++ /库/ armeabi来的路径和显式链接\"/<$c$c>home/user/android-ndk-r5b/toolchains/arm-linux-androideabi-4.4.3/$p$pbuilt/linux-x86/arm-linux-androideabi/lib/thumb/libsupc++.a\"所有包括包裹在一个库 - 启动组--end组条款

It turns out I needed to add -L/home/user/android-ndk-r5b/sources/cxx-stl/gnu-libstdc++/libs/armeabi" to the path and explicitly link "/home/user/android-ndk-r5b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/arm-linux-androideabi/lib/thumb/libsupc++.a" with all include libraries wrapped in a "--start-group --end-group" clause.

希望这可以帮助其他人了。

Hopefully this helps someone else too.

这篇关于Android的NDK R5B外部构建和supc ++链接问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆