![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| static and shared libraries | JamesByars | UNIX for Advanced & Expert Users | 2 | 01-13-2008 02:29 PM |
| debugging shared objects | yakari | UNIX for Advanced & Expert Users | 0 | 10-03-2006 01:14 PM |
| How about finding out all objects by owner | HAA | Shell Programming and Scripting | 3 | 05-29-2006 06:07 AM |
| Shared Objects | Yura | UNIX for Advanced & Expert Users | 3 | 09-02-2005 01:25 PM |
| Shared Objects | mrgubbala | UNIX for Dummies Questions & Answers | 3 | 03-02-2005 02:35 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Static objects in libraries
Hi! I have the following problem with C++ programs on Unix: There is a binary executable program called, e.g. Main. It is dynamically linked with two shared libraries: Shared1 and Shared2. Both of these libraries, in turn, are statically linked with a static library called Static. This static library has a static object called StaticObj declared and defined as: Code:
class MyClass
{
public:
static MyClass StaticObj;
};
MyClass MyClass::StaticObj;
Now, when I run the execucable Main, I get into the problem that StaticObj is initialized twice. This means that MyClass constructor is called twice on the same address. The same story happens with the destructors. It is naturally that such behaviour would not be desired, especially when you deal with some objects that have states. Neither is applicable variant, which makes two independed copies of StaticObj for libraries Shared1 and Shared2 (imagine that StaticObj is a mutex!). Has anyone run across a similar problem and found a good solution? Thanks! |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|