help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Static data members in shared objects


From: Robert Heller
Subject: Re: Static data members in shared objects
Date: Fri, 21 Apr 2006 14:46:03 +0200

  Suneeel@gmail.com,
  In a message on 21 Apr 2006 02:13:10 -0700, wrote :

S> Hi all,
S> 
S> I'm having a problem with a shared object i've written. I have a class
S> with a couple of private static data members.
S> The class declaration is in a .h file and the member function
S> definitions are in a .cpp file.
S> 
S> I'm compiling the shared object with -fPIC and -shared.
S> 
S> The code compiles fine, but when I try to use the shared object, I get
S> a linker error saying  undefined reference to `CSomeClass::m_SomeVar'
S> where m_SomeVar is the private static member.
S> The same is hapning for the other static memver variables as well.
S> 
S> Is there some issue with using static data members in shared objects ?

No.  In addition to *declaring* the static members in the header (.h),
you need to properly *define* them in *one* .cpp file.  What exactly
do your definitions look like?  Are *exactly* how are you linking the
shared library?  You should post actual code (or code fragments) AND
possibly parts of your Makefile(.in,.am) (you are using a Makefile?)

S> 
S>                            

Robert Heller             -- 978-544-6933
Deepwoods Software        -- Linux Installation and Administration
http://www.deepsoft.com/  -- Web Hosting, with CGI and Database
heller@deepsoft.com       -- Contract Programming: C/C++, Tcl/Tk






                                                                


reply via email to

[Prev in Thread] Current Thread [Next in Thread]