2016-07-08 1 views
1

Je suis actuellement en train d'essayer de construire une bibliothèque statique de certains fichiers source C++ nécessitant un boost. J'ai suivi l'exemple hello-libs et ont avec succès lié BOOST dépendances de fichiers statiques comme cela se fait dans l'échantillon example.Now dit que, pendant tout en construisant le module que je reçois ces erros:Android linker NDK Erreur: erreur: référence non définie à 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

J'avais essayé de résoudre ce problème et était venu sur de nombreuses solutions sur elle-même stackoverflow, ce qui suggère que je devrait modifier mon chemin de liaison et libC++ inclus. si la bibliothèque

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

Je suis confus de ce qui devrait être fait. Merci de me suggérer des moyens de résoudre ce problème. Merci :))

Répondre

3

Il semble que vos bibliothèques boost aient été construites avec gnustl (ou peut-être stlport), alors que vous utilisez libC++. Vous ne pouvez pas mélanger et faire correspondre des LIST car ils ne sont pas compatibles avec ABI.

Si vous remplacez stl = "c++_shared" avec stl = "gnustl_shared" (ou peut-être stlport_shared alors il devrait établir un lien. Vous pouvez également construire boost contre c++_shared.

+0

yups qui était le problème. A résolu :)) Mais je recevais gnustl_shared la référence non définie à "to_chars". Enfin, j'ai dû commenter tous les messages de trace et cela a fonctionné. – cRAN

+0

Bonjour @cRAN Je rencontre un problème similaire avec des références non définies à 'to_chars'; pourriez-vous élaborer sur ce que vous entendez par «commenter tous les messages de trace»? Merci! –

+0

'' 'TRACE (" Attente du lecteur à ("<< endpoint.address(). To_string() <<", " << std :: to_string (endpoint.port()) <<") ") '' ' quelque chose comme ça – cRAN