2016-07-08 40 views
1

私は現在、ブーストが必要ないくつかのソースC++ファイルの静的ライブラリを構築しようとしています。私はモジュールを構築しながら、中に私はこれらのerrosを得る、と言っexample.Now hello-libsたとえば、次のされているサンプルで行われるように成功ブースト静的ファイルの依存関係をリンクしていますAndroid NDKリンカエラー:エラー:未定義のstd :: basic_stringへの参照

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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&)'

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

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

私がしようとしていましたこれを解決し、私は私のリンカのパスを修正し、libcを含ま++。

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']) 
    } 

ので、ライブラリと、私は何をすべきかの混乱していなければならないことを示唆し、stackoverflowの自体に多くのソリューション時に来ていました。どのように私はこの問題を解決することができますかの方法を提案してください。ありがとう:))

答えて

3

libC++を使用しているのに対し、gnustl(または多分stlport)に対してあなたのboostライブラリが構築されているようです。 STLはABIと互換性がないため、混在させることはできません。しかしgnustl_shared私は未定義の参照になっていたと (。:)それを解決し、それがリンクする代わりにc++_sharedに対してブーストを構築する。問題だった

+0

Yupsを。または多分stlport_shared

あなたはstl = "gnustl_shared"stl = "c++_shared"を交換した場合"to_chars"。ついに、私はすべてのトレースメッセージをコメントアウトしなければなりませんでした。 – cRAN

+0

こんにちは@cRAN私は 'to_chars'への未定義の参照で同様の問題に遭遇しています。 「すべてのトレースメッセージをコメントアウトする」という意味を詳しく説明できますか?ありがとう! –

+0

'' 'TRACE(" << "endpoint.address()。to_string()<<"、 " << std :: to_string(endpoint.port()) <<") " ); '' ' このようなもの – cRAN

関連する問題