$ CC -flags
-instlib=<library> Inhibit generation of instances already in <library>
The option causes the the compiler to scan the named library for template instances (and inline functions generated out of line), then omit generating them in the current .o file. Therefore, by specifying -instlib=./libbase.so when building libtest.so, the instantiated template "
std::basic_string<unsigned int> str" would not be linked into libtest.so. So that the cyclic dependencies would not happen.
I added this option in the Makefile.am of im-scim.so, and it worked as expected.
You could refer to [osol-tools-linking] thread for details.