[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: static members in shared libraries
From: |
Paul Pluzhnikov |
Subject: |
Re: static members in shared libraries |
Date: |
Wed, 12 Jul 2006 20:11:18 -0700 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Jumbo Shrimp, linux) |
"Spaceman" <staceyj71@yahoo.co.uk> writes:
> If I compile this to generate the shared library and executable using
> the -fPIC option I get the following output:
>
> My Value= 10;
> My Value= 99;
> My Value= 99;
That's correct output ...
> However, The output I would expect is:
> My Value= 10;
> My Value= 99;
> My Value= 10;
Your expectations are incorrect (probably influenced by your
experience with Win32 DLL model, which is very different from all
other UNIXes (except AIX)).
> Can anyone please help with this?
You need to specify platform (I'll assume Linux/x86_64).
You can get behaviour similar to Win32 by linking the shared library
with -Bsymbolic linker flag (prefix it with -Wl, when using 'gcc'
or 'g++'), or by localizing CommonElement::m_static with a linker
version script (info ld -> Scripts -> VERSION).
Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.