Android NDK链接器错误:错误:对std :: basic_string的未定义引用 [英] Android NDK linker Error:error: undefined reference to std::basic_string

查看:1125
本文介绍了Android NDK链接器错误:错误:对std :: basic_string的未定义引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试建立一些需要增强功能的源c ++文件的静态库.我一直在遵循 hello-libs 示例,并已成功链接增强了静态文件的依赖关系,如示例示例中所示.现在,在构建模块的过程中,我得到了这些错误提示:

I am currently trying to build a static library of some source c++ files requiring boost. I have been following the hello-libs example and have successfully linked the boost static file dependencies as is done in the sample example.Now said that, during while building the module I get these erros :

错误:错误:对'std :: basic_string,std :: allocator> :: basic_string(char const *,std :: allocator const&)'的未定义引用

Error:error: undefined reference to 'std::basic_string, std::allocator >::basic_string(char const*, std::allocator const&)'

错误:错误:对'std :: runtime_error :: runtime_error(std :: string const&)'的未定义引用

Error:error: undefined reference to 'std::runtime_error::runtime_error(std::string const&)'

错误:错误:对'std :: _ Rb_tree_decrement(std :: _ Rb_tree_node_base *)'的未定义引用

Error:error: undefined reference to 'std::_Rb_tree_decrement(std::_Rb_tree_node_base*)'

错误:错误:对'std :: string :: _ Rep :: _ S_empty_rep_storage'的未定义引用

Error:error: undefined reference to 'std::string::_Rep::_S_empty_rep_storage'

错误:错误:对'std :: basic_string,std :: allocator> ::〜basic_string()'的未定义引用

Error:error: undefined reference to 'std::basic_string, std::allocator >::~basic_string()'

错误:错误:对'std :: string :: _ Rep :: _ M_dispose(std :: allocator const&)'的未定义引用

Error:error: undefined reference to 'std::string::_Rep::_M_dispose(std::allocator const&)'

错误:错误:对'std :: runtime_error :: runtime_error(std :: string const&)'的未定义引用

Error:error: undefined reference to 'std::runtime_error::runtime_error(std::string const&)'

错误:错误:对'std :: string :: _ Rep :: _ M_destroy(std :: allocator const&)'的未定义引用

Error:error: undefined reference to 'std::string::_Rep::_M_destroy(std::allocator const&)'

错误:错误:对'std :: basic_string,std :: allocator> :: basic_string(std :: string const&)'的未定义引用

Error:error: undefined reference to 'std::basic_string, std::allocator >::basic_string(std::string const&)'

错误:错误:对'std :: _ Rb_tree_increment(std :: _ Rb_tree_node_base *)'的未定义引用

Error:error: undefined reference to 'std::_Rb_tree_increment(std::_Rb_tree_node_base*)'

错误:错误:对'std :: string :: _ Rep :: _ S_empty_rep_storage'的未定义引用

Error:error: undefined reference to 'std::string::_Rep::_S_empty_rep_storage'

错误:错误:对'std :: string :: _ Rep :: _ M_destroy(std :: allocator const&)'的未定义引用

Error:error: undefined reference to 'std::string::_Rep::_M_destroy(std::allocator const&)'

错误:错误:对'std :: basic_string,std :: allocator> :: basic_string(std :: string const&)'的未定义引用

Error:error: undefined reference to 'std::basic_string, std::allocator >::basic_string(std::string const&)'

错误:错误:对'std :: string :: _ Rep :: _ M_destroy(std :: allocator const&)'的未定义引用

Error:error: undefined reference to 'std::string::_Rep::_M_destroy(std::allocator const&)'

错误:错误:对'std :: _ Rb_tree_increment(std :: _ Rb_tree_node_base const *)'的未定义引用

Error:error: undefined reference to 'std::_Rb_tree_increment(std::_Rb_tree_node_base const*)'

错误:错误:对'std :: _ Rb_tree_rebalance_for_erase(std :: _ Rb_tree_node_base *,std :: _ Rb_tree_node_base&)'的未定义引用

Error:error: undefined reference to 'std::_Rb_tree_rebalance_for_erase(std::_Rb_tree_node_base*, std::_Rb_tree_node_base&)'

错误:错误:对'std :: string :: _ Rep :: _ S_empty_rep_storage'的未定义引用

Error:error: undefined reference to 'std::string::_Rep::_S_empty_rep_storage'

错误:错误:对'std :: string :: _ Rep :: _ S_empty_rep_storage'的未定义引用

Error:error: undefined reference to 'std::string::_Rep::_S_empty_rep_storage'

错误:错误:对'std :: basic_string,std :: allocator> :: basic_string(char const *,std :: allocator const&)'的未定义引用

Error:error: undefined reference to 'std::basic_string, std::allocator >::basic_string(char const*, std::allocator const&)'

错误:错误:对'std :: basic_string,std :: allocator> :: basic_string(std :: string const&)'的未定义引用

Error:error: undefined reference to 'std::basic_string, std::allocator >::basic_string(std::string const&)'

错误:错误:链接器命令失败,退出代码为1(使用-v查看调用)

Error:error: linker command failed with exit code 1 (use -v to see invocation)

错误:错误:对'std :: basic_string,std :: allocator> :: basic_string(char const *,std :: allocator const&)'的未定义引用

Error:error: undefined reference to 'std::basic_string, std::allocator >::basic_string(char const*, std::allocator const&)'

错误:错误:对'std :: string :: _ Rep :: _ M_destroy(std :: allocator const&)'的未定义引用

Error:error: undefined reference to 'std::string::_Rep::_M_destroy(std::allocator const&)'

错误:错误:对'std :: _ Rb_tree_rebalance_for_erase(std :: _ Rb_tree_node_base *,std :: _ Rb_tree_node_base&)'的未定义引用

Error:error: undefined reference to 'std::_Rb_tree_rebalance_for_erase(std::_Rb_tree_node_base*, std::_Rb_tree_node_base&)'

错误:错误:对'std :: string :: _ Rep :: _ M_dispose(std :: allocator const&)'的未定义引用

Error:error: undefined reference to 'std::string::_Rep::_M_dispose(std::allocator const&)'

错误:错误:对'std :: basic_string,std :: allocator> :: basic_string(char const *,std :: allocator const&)'的未定义引用

Error:error: undefined reference to 'std::basic_string, std::allocator >::basic_string(char const*, std::allocator const&)'

错误:错误:对'std :: _ Rb_tree_insert_and_rebalance(bool,std :: _ Rb_tree_node_base *,std :: _ Rb_tree_node_base *,std :: _ Rb_tree_node_base&)'的未定义引用

Error:error: undefined reference to 'std::_Rb_tree_insert_and_rebalance(bool, std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::_Rb_tree_node_base&)'

错误:任务':dummy:linkDummyArmeabiDebugSharedLibrary'的执行失败.

Error:Execution failed for task ':dummy:linkDummyArmeabiDebugSharedLibrary'.

构建操作失败. 链接libdummy.so时,链接器失败. 请参阅以下完整日志:file:///home/cran-cg/Downloads/Hello-libs-boost/name/build/tmp/linkDummyArmeabiDebugSharedLibrary/output.txt

A build operation failed. Linker failed while linking libdummy.so. See the complete log at: file:///home/cran-cg/Downloads/Hello-libs-boost/name/build/tmp/linkDummyArmeabiDebugSharedLibrary/output.txt

我一直在尝试解决此问题,并针对stackoverflow本身提出了许多解决方案,建议我修改链接器路径并包括libc ++.so库

I had been trying to resolve this and had come upon many solutions on stackoverflow itself, suggesting that I should amend my linker path and include libc++.so library

ndk{
        moduleName = 'p2psp'
        stl = "c++_shared"
       // ldLibs.addAll('-L'+ file("/home/cran-cg/Android/Sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/libs/armeabi").absolutePath)
        ldLibs.addAll(['android', 'log','atomic'])/*"${NDK_ROOT}/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi",'gnustl_static'*/
        toolchain = "clang"
        cppFlags.add("-std=c++11")
        cppFlags.add('-frtti')
        cppFlags.add('-fexceptions')
        cppFlags.addAll('-I' + file("/home/cran-cg/Android/Sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/libcxx/include").absolutePath ,'-DANDROID', ' -DANDROID_NDK', '-DAWS_CUSTOM_MEMORY_MANAGEMENT', '-fPIC', '-fexceptions')
        //cppFlags.add("-I${lib_distribution_root}/boost/include".toString())
        //cppFlags.add("-I${file("src/main/jni/inc")}".toString())

        abiFilters.addAll(['armeabi'])//, 'armeabi-v7a', 'x86'])
    }

我对应该做什么感到困惑.请建议我有关如何解决此问题的方法.谢谢:))

And I am confused of what should be done. Please suggest me ways as to how can I resolve this issue. Thanks :))

推荐答案

看起来您的Boost库是针对gnustl(或也许是stlport)构建的,而您使用的是libc ++.您不能混合和匹配STL,因为它们与ABI不兼容.

It looks like your boost libraries were built against gnustl (or maybe stlport), whereas you're using libc++. You can't mix and match STLs as they are not ABI compatible.

如果将stl = "c++_shared"替换为stl = "gnustl_shared"(或者可能是stlport_shared,则它应该链接.或者针对c++_shared建立增强功能.

If you replace stl = "c++_shared" with stl = "gnustl_shared"(or maybe stlport_shared then it should link. Alternatively build boost against c++_shared.

这篇关于Android NDK链接器错误:错误:对std :: basic_string的未定义引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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