Sign in to follow this  

global variables in shared objects problem in linux

Recommended Posts

Hi everyone, I have the following problem when I build shared object in linux. I have a global std::map in the shared object, and when I try to use it within shared object initialization, I app crashes. Does anyone have an idea what the problem is ? Here is my source : ________________________________________________________________________________ std::map <std::string, unsigned int> t; // shared object constructor ( called upon void __attribute__ ((constructor)) my_init(void) { std::string a="a", b="b"; t[a] = 0; // this works t[b] = 1; // <- and here app crashes here with segfault somewhere inside the std::map } ________________________________________________________________________________ Thanks in advance for any help

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this