I have a static string defined in a class:
class Foo
{
public:
...
static const std::string default_name;
...
};
In the C++ file:
const std::string Foo::default_name("standard");
The C++ file is compiled into a shared library, say libfubar.so
The executable is built:
g++ main.cc -o fubar -L<path to libraries> -lfubar
In the real case I have about a dozen libraries. To execute the code, I
manually update LD_LIBRARY_PATH to point to the shared libraries
including the RogueWave STL implementation, but I segfault in
std::string when it is accessing Foo::default_name.
I have tested with and without const. The backtrace shows that we are
in the default constructor, Foo().
As a work around, I could possibly use a c language string (eg. char
*), or even simply define the string as a manifest constant, but my
preference is to use the STL string.
--
Jerry Feldman