Linking problem solved
Some time ago, I wrote in my blog about a linker problem g++ on AIX. Something like this
g++: -b must come at the beginning of the command line.
Well, I discovered that I could replace my '-b' parameters with -Wl,-b, and the linker would accept the parameters as valid. However, ld on AIX doesn't like this part of a singleton class.
template <typename T>
{
static T* _instance;
};
template <typename T>
This worked fine everywhere else, (HP-UX, Solaris, Linux, Windows, OSF) but not on AIX.
The solution was to use a static local variable, instead of a static class variable.
This seems to work, all four processes link, except one of them uses libcppunit, and this doesn't seem to work on AIX. :-(
2 Comments:
Hi, I have the same problem on AIX. i have been using this class for years, but it does not work on AIX.
can you please post your solution?
template
class CSingletonT
{
public:
static T* Instance()
{
static T theT;
return &theT;
}
private:
CSingletonT();
CSingletonT(CSingletonT &rhs);
CSingletonT &operator=(CSingletonT &rhs);
~CSingletonT();
};
It was a very long time ago, but I seem to recall solving it the same way you have done using the static local variable.
I was using GCC 3.3.4.
Post a Comment
<< Home