共有ライブラリに次の問題があります
共有ライブラリを作成する
class A
{
static int callCount;
A() { callCount++; }
}
int A:callCount = 0;
class Main
{
Main()
{
A a1();
A a2();
}
}
この共有ライブラリをさらに何度もロードするプロセスを作成し、callCount がプロセス全体ではなく共有ライブラリのみに属するようにしたい
dlopen("shared.so", RTLD_LAZY);
// after some code i can construct Main()
// and now i will open the shared object again
dlopen("shared.so", RTLD_LAZY);
// now if i construct Main from the new library i want to have a new
// initialized callCount eq 0 but its 2
どうすればこの問題を解決できますか