mardi 3 décembre 2019

why there is difference when build static lib and dynamic lib in solaris11.3 on x86?

I am using solaris 11.3 on x86m, using gcc 4.8.2. I want to compile two types of library files: dynamic library and static library for the same code.
First i compiled the dynamic library and test in app, It works ok.
But when i compiled the static library(test in app),It works not ok. There is link error, like:
Undefined first referenced
symbol in file
std::__detail::_Prime_rehash_policy::_M_next_bkt(unsigned int) const in xxxx file
std::ctype::_M_widen_init() const in xxxx file
std::_Hash_bytes(void const*, unsigned int, unsigned int) in xxxx file
std::basic_string, std::allocator >::basic_string(std::basic_string, std::allocator >&&) in xxxx file

I using the strings command to look up to undefined symbol. In first I check the libstdc++.so, there is no no information to related symbols. In the dynamic lib(libxxx.so) there is no references to related symbols. In the static lib(libxxx.a), there is indeed references to related symbols. Just like:

strings libxxx.so | grep _M_widen_init

nothing to export

strings libxxx.a | grep _M_widen_init

the export is like:
_ZNKSt5ctypeIcE13_M_widen_initEv
_ZNKSt5ctypeIcE13_M_widen_initEv
_ZNKSt5ctypeIcE13_M_widen_initE

Why the static lib contents undefined symbols? How should i adjust the compile and link options to solve this problem?

Aucun commentaire:

Enregistrer un commentaire