Problem with static variable and C++ object embedded in a dynamic library

Problem with static variable and C++ object embedded in a dynamic library

OS : Redhat 6.3
Compiler : icpc 13.0.1

Hi,

I've got some trouble with a static variable inside C++ object embedded in a dynamic library loaded by ltmm (plugin).

The C++ object inherits from a template class Singleton which use the static variable (private).

If I build my plugin with g++ 4.4.6, the compiler generate one instance of the static variable in .bss section with  flag bind "unique" (objdump).

If I build my plugin with icpc 13.0.1, the compiler generate several instance of the static variable in .data section with  flag bind "weak" (objdump).

How to obtain only one instance of a static variable with icpc in a shared library ?

Best regards,

3 posts / 0 nouveau(x)
Dernière contribution
Reportez-vous à notre Notice d'optimisation pour plus d'informations sur les choix et l'optimisation des performances dans les produits logiciels Intel.

>>...If I build my plugin with icpc 13.0.1, the compiler generate several instance of the static variable in .data section
>>with flag bind "weak" (objdump).
>>
>>How to obtain only one instance of a static variable with icpc in a shared library ?

Please post a piece of code which demonstrates how the static variable is declared, initialized and used in a test case. Thanks.

Hi,

I extracted a piece of code and add a makefile to use it.

In "informations.txt" , you can see that the objects sbr::Singleton<sbr::Object1>::_instance and sbr::Singleton<sbr::Object2>::_instance don't have the same bind flag. I don't known how to get an unique instance for this objects with the icpc compiler. How do I declare  _instance to get  a behavior like GNU compiler ?

Regards,

Fichiers joints: 

Fichier attachéTaille
Télécharger problib.tar.gz2 Ko

Laisser un commentaire

Veuillez ouvrir une session pour ajouter un commentaire. Pas encore membre ? Rejoignez-nous dès aujourd’hui