mercredi 14 septembre 2016

Clang++ does name mangling inspite of extern "C" when using -lstdc++

I build a shared-object using Clang++. The major functions are located in 'extern "C"' block. The building is fine, and I can call these functions using JNA.

When I added the flag "-lstdc++" (for using some C++11 features) - I got runtime error:

undefined symbol: _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm

I run

nm target/classes/linux-x86-64/libCloudCryptoLibrary.so  |grep init

then I get

                 U _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm
                 U _ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEmc
0000000000004860 T _init
0000000000024360 T init

When I remove that flag, and run nm again, I get:

                 U _ZNKSt5ctypeIcE13_M_widen_initEv@@GLIBCXX_3.4.11
000000000026b920 b _ZStL8__ioinit
000000000026b9e0 b _ZStL8__ioinit
0000000000004508 T _init
0000000000021000 T init

What can I do for correct it?

Aucun commentaire:

Enregistrer un commentaire