nm 可以通过查看符号表查看so中是否定义了某个函数,这个特性可以用于解决如下情况:
在某次编译过程中出现undefined reference to "xxx";
说明
出现以上情况说明程序编译已经通过,但是在链接过程中"xxx"符号找不到来源(定义definition或说明declaration),往往出现在动态链接的过程中,需要在程序外部寻找到支持“xxx”的链接库。以某一次android ndk交叉编译过程中c++标准库缺失为例。
问题
third/CRF++-0.58/encoder.o:encoder.cpp:function std::basic_filebuf<char, std::char_traits<char> >::imbue(std::locale const&): error: undefined reference to 'std::locale::_M_get_facet(std::locale::id const&) const'
third/CRF++-0.58/encoder.o:encoder.cpp:function std::basic_filebuf<char, std::char_traits<char> >::imbue(std::locale const&): error: undefined reference to 'std::locale::_M_use_facet(std::locale::id const&) const'
third/CRF++-0.58/encoder.o:encoder.cpp:function std::basic_filebuf<char, std::char_traits<char> >::imbue(std::locale const&): error: undefined reference to 'std::locale::_M_use_facet(std::locale::id const&) const'
third/CRF++-0.58/encoder.o:encoder.cpp:function std::basic_filebuf<char, std::char_traits<char> >::imbue(std::locale const&): error: undefined reference to '__cxa_call_unexpected'
third/CRF++-0.58/encoder.o:encoder.cpp:function std::basic_filebuf<char, std::char_traits<char> >::imbue(std::locale const&): error: undefined reference to 'std::codecvt<char, char, mbstate_t>::id'
third/CRF++-0.58/encoder.o:enc